Aug 30, 2013 at 7:32am UTC
Hi Everyone! Can you help me do this program because i am a beginner. =)
Here is the sample output:
Enter Number: 5
Solution:
5 x 4 x 3 x 2 x 1
Result is 120
Using WHILE LOOP CODE!!
TY IN ADVANCE TO THOSE WHO WILL HELP ME! :)
Aug 30, 2013 at 7:43am UTC
#include <stdio.h>
int main()
{
int n;
while(scanf("%d", &n) == 1)
{
int r = 1;
while(n > 0)
r *= (n--);
printf("%d\n", r);
}
return 0;
}
Aug 30, 2013 at 5:17pm UTC
@ ciphermagi: Too late, he's already been given the full solution in his duplicate thread.
Aug 30, 2013 at 8:22pm UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
int main()
{
using namespace std;
int a;
a = 5;
int b;
b = a;
while (a > 1){
b *= (a-1);
a-=1;
}
cout << b << endl;
}
My output was 120. Hope this helps
Last edited on Aug 30, 2013 at 8:23pm UTC
Aug 30, 2013 at 9:34pm UTC
i agree with @cnoeval. cant you give it 10 minutes to make one. believe me it is that easy
Last edited on Aug 30, 2013 at 9:34pm UTC