Answer to Question #16433 in C++ for arif hussain

Question #16433
Q#1 • Write a program to find the factorial of a number using structure
1
Expert's answer
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS