Answer to Question #15339 in C++ for reymark

Question #15339
write a program that will compute n! (factorial) which is the product of all number from1 to n.
1
Expert's answer
2012-09-28T07:57:00-0400
#include<iostream.h>

int factorial(int n){
int res=1;
for(int i = 1; i <= n; i++)
& res = res*i;
return res;
}

void main(){
int m;
cout<<"Enter an integer: ";
cin>>m;
cout<<factorial(m)<<"\n";

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS