Simplest factorial program,use of one for loop . Program designed in simple logic so enjoy...
User can enter any desire valid input for the factorial output..
Source Code:-
#include<iostream.h>
#include<conio.h>
void main()
{ clrscr();
float n,i;
float a=1;
cout<<"Program for Factorial of any Number (by: Tarun Rawat)\n\n";
cout<<"enter a value ";
cin>>n;
for(i=1;i<=n;i++)
{a=a*i;}
cout<<"factorial is "<<a;
getch();
}
User can enter any desire valid input for the factorial output..
#include<iostream.h>
#include<conio.h>
void main()
{ clrscr();
float n,i;
float a=1;
cout<<"Program for Factorial of any Number (by: Tarun Rawat)\n\n";
cout<<"enter a value ";
cin>>n;
for(i=1;i<=n;i++)
{a=a*i;}
cout<<"factorial is "<<a;
getch();
}
No comments:
Post a Comment