Monday, February 6, 2017

Factorial of a Number in C++


Factorial of any number is the product of an integer and all the integers below it for example factorial of 4 is
4! = 4 * 3 * 2 * 1 = 24

Factorial program in C++ using for Loop


#include<iostream.h>
#include<conio.h>

void main()
{
int i, no, fact=1;
clrscr();
cout<<"Enter the any no. : ";
cin>>no;
for(i=1;i<=no;i++)
{
fact=fact*i;
}
cout<<"Factorial: "<<fact;
getch();
}

No comments:

Post a Comment

Element of html

<!DOCTPE html> <html> <head> <title>hi</title> </head> <body> <p>This text is normal....