Finding Factorial
using System;
class no
{
int a,fact;
public void input()
{
Console.WriteLine("Enter the number for finding Factorial:");
a=Convert.ToInt32(Console.ReadLine());
}
public void output()
{
int f=1,i;
for(i=1;i<=a;i++)
{
f=f*i;
}
Console.WriteLine("Factorial of the entered number is:{0}",f);
}
}
class Factorial
{
public static void Main(String[] args)
{
no obj=new no();
obj.input();
obj.output();
}
}
class no
{
int a,fact;
public void input()
{
Console.WriteLine("Enter the number for finding Factorial:");
a=Convert.ToInt32(Console.ReadLine());
}
public void output()
{
int f=1,i;
for(i=1;i<=a;i++)
{
f=f*i;
}
Console.WriteLine("Factorial of the entered number is:{0}",f);
}
}
class Factorial
{
public static void Main(String[] args)
{
no obj=new no();
obj.input();
obj.output();
}
}
output:
No comments:
Post a Comment