write code for Factorial?

Answer Posted / diana cheriyan

Using System;
Namespace FactNmspce
{
Class FactCls
{
Public Static Void Main(String[]args)
{
int i,n,fact=1;
Console.WriteLine("Enter Number");
n=int.Parse(Console.ReadLine());
for(i=1;i<=n;i++)
{
fact=fact*i;
}
Console.WriteLine("Factorial is {0}",fact);
}
}
}

Is This Answer Correct ?    12 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the generation of Garbage Collection in C# .NET ?

726


What does readonly mean in c#?

736


What is difference between dll and exe in c#?

660


Explain different properties of object oriented systems.

677


what is IDisposal interface,IComparable,IEquatable,IFormatable

730


What's the difference between abstraction and encapsulation?

654


Can a constructor be static in c#?

731


What is an indexer in c#?

729


Can we overload the main method in c#?

664


Difference between type constructor and instance constructor? What is static constructor, when it will be fired? And what is its use?

734


What is gac? What are the steps to create an assembly and add it to the gac?

670


Can I define a type that is an alias of another type (like typedef in c++)?

752


What types of object can I throw as exceptions?

721


Why do we need interfaces in c#?

644


Describe a Struct ?

728