تمرین سی پلاس-فاکتوریل
//factorial
#include<iostream.h>
#include<conio.h>
void main(){
float f,r,w;
while(f!=-1){
w=1;
clrscr();
cout<<"Enter a number to anlyse factorial(Exit = 0 ): ";
cin>>f;
if (f<1){
return; }
else {
cout<<"\n"<<"========================================================="<<"\n"<<"\n";
cout<<"Factorial: ";
while(f>=2){
cout<<f<<" * ";
r=f--;
w=w*r;
}
cout<<"1";
cout<<"\n"<<"\n"<<"Result: "<<w;
}
cout<<"\n"<<"\n"<<"Press any key to reset!!!"<<"\n"<<"\n"<<"========================================================="<<"\n";
getch();
}
}
اگه سوالی داشتید بپرسید