Task 0

ABBA Factorial Program

This task demonstrates recursion and factorial calculation in C#. The program asks the user for the number of vowels and consonants and outputs the product of their factorials.

C# Source Code

using System;

class ABBA
{
    static int Factorial(int n)
    {
        if (n == 1) return 1;
        return n * Factorial(n - 1);
    }

    static void Main(string[] args)
    {
        Console.WriteLine("ABBA!");

        Console.Write("Enter number of vowels: ");
        int vowels = int.Parse(Console.ReadLine());

        Console.Write("Enter number of consonants: ");
        int consonants = int.Parse(Console.ReadLine());

        Console.WriteLine(
            Factorial(vowels) *
            Factorial(consonants)
        );
    }
}
Web hosting by Somee.com