Welcome to PAKITWORLD!
I hope you will find PAKITWORLD forum useful...



 
HomeCalendarFAQSearchMemberlistUsergroupsLog inRegister
Search
 
 

Display results as :
 
Rechercher Advanced Search
Freelancer.com
Visitors
Live Trafic

Share | 
 

 Factorial in C++

View previous topic View next topic Go down 
AuthorMessage
Admin
Admin


Posts : 216
Join date : 2011-06-17
Location : Rawalpindi

PostSubject: Factorial in C++   Thu Oct 27, 2011 5:39 am


Factorial in C++



#include
#include
#include
double factorial(int a);
void main(void)
{
int a;
clrscr();
cout << "Press 0 \'Zero\' to terminate the program!" << endl;
do
{
cout << "Please enter any number? ";
cin >> a;
cout << "The factorial of " << a << " is " << factorial(a) << " ." << endl;
}
while(a!=0);
getch();
}
double factorial(int a)
{
int f;
f=1;
while(a>1)
{
f*=a;
a--;
}
return f;
}

Back to top Go down
View user profile http://pakitworld.board-directory.net
 
Factorial in C++
View previous topic View next topic Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
 :: Programming :: C & C++-
Jump to: