Q-1 Program To find out Febonacii Series of any number....
Ans:
class Program
{
static void Main(string[] args)
{
int i, a = 0, b = 1, c;
Console.WriteLine("enter the number");
int num = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(a);
Console.WriteLine(b);
for (i = 0; i < num; i++)
{
c = a + b;
a = b;
b = c;
Console.WriteLine(c);
}
Console.ReadLine();
}
}
Q.2 Program to find out Factorial of any number.
Ans:
class Program
{
static void Main(string[] args)
{
int fact=1,n;
Console.WriteLine("Enter A Number:");
n = Convert.ToInt32(Console.ReadLine());
for (int i=1; i<=n; i++)
{
fact = fact * i;
}
Console.WriteLine(fact);
Console.ReadLine();
}
}
No comments:
Post a Comment