60 487
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #25206 in C# for Malik

Question #25206
Develop a serial program to calculate a factorial using a for loop. No recursion. Time it.

to be done in c language.
Expert's answer
#include <iostream>
using namespace std;
void main()
{
int enteredNumber;
long result = 1;
printf("%s","enter the number from 1 to 16\n");
/*entered number can not exceed 16,
otherwise the program will give the wrong result,
because the results size will exceed of the 8 bytes*/
scanf("%d",&enteredNumber);
if(enteredNumber > 16)
{
printf("%s","entered number can not exceed 16,otherwise the program will give the wrong result,because the results size will exceed of the 8 bytes\n");
return;
}
for( int i = 1; i<=enteredNumber; i++ )
{
if(enteredNumber == 1)break;
result *= i;
}
printf("%d",result);
}

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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions