Answer to Question #16433 in C++ for arif hussain
Q#1 • Write a program to find the factorial of a number using structure
1
2012-10-17T09:38:01-0400
#include<iostream>
using namespace std;
struct factorial{
long unsigned int num, fac;
} f;
factorial *F;
void main(){
F = &f;
cout<<"enter a positive integer: ";
cin>>F->num;
F->fac = 1;
for (int i=2; i<=F->num; ++i) F->fac *= i;
cout<<F->num<<"! = "<<F->fac<<"\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!
Learn more about our help with Assignments:
C++
Comments
Leave a comment