please make a factorial number that the output is like this:

Enter a number:5

5!=1*2*3*4*5
5!=120

likewise

Enter a number:6
6!=1*2*3*4*5*6
6!=720

using for loop statement only.

use this
example:
#include <stdio.h>
#include <conio.h>
........etc.

7
Contributors
8
Replies
9
Views
8 Years
Discussion Span
Last Post by WaltP

Post your attempt to solve the problem.

please make a factorial number that the output is like this:

Enter a number:5

5!=1*2*3*4*5
5!=120

likewise

Enter a number:6
6!=1*2*3*4*5*6
6!=720

using for loop statement only.

use this
example:
#include <stdio.h>
#include <conio.h>
........etc.

``````#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,f;
clrscr();
f=1;
printf("enter no");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
f=f*i;
}
printf("fac=%d",f);
getch();
}``````

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

1st- you didn't read any of the rules. 2nd-You didn't read the previous post. 3rd-We DO NOT give away code. 4th-Format your code
Don't post complete solutions to homework problems.

here what you want.
the code is developed with tc++ ver.3.0

``````#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();

int i,j,n,d,k;
printf( "\n Enter the no.:  " );
scanf( "%d",&n );
printf( "\n\n %d! = ",n );

for( i = 0,k = j = n; i < 5; i++ )
{
if( k == 1 )
printf( "%d ", k );
else
printf( "%d * ", k );

k = k - 1;

if( k > 0 )
n = n * k;

}

printf( "\n\n %d! = %d",j,n );

getch();
}``````

i think it solves your problem. Have a good day!

Not only that but the code is non-standard and not worthy of teaching.
Don't post complete solutions to homework problems. Did you not read the post immediately above this one??

please make a factorial number that the output is like this:

Enter a number:5

`5!=1*2*3*4*5`
`5!=120`

likewise

Enter a number:6
`6!=1*2*3*4*5*6`
`6!=720`

using for loop statement only.

please do not use `#include<iostream.h>`...

use this
example:
`#include <stdio.h>`
`#include <conio.h>`
........etc.

``````#include<stdio.h>#include<conio.h>void main(){int i,n,f;clrscr();f=1;printf("enter no");scanf("%d",&n);for(i=1;i<=n;i++){f=f*i;}printf("fac=%d",f);getch();}#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,f;
clrscr();
f=1;
printf("enter no");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
f=f*i;
}
printf("fac=%d",f);
getch();
}
``````

Edited by mike_2000_17: Fixed formatting

This is even worse code than the previous poster. It uses the same bad techniques and adds even more.
OMG that's worse than your first post.

@micjan : Congrats you got the code !!! I certainly wish the two smart people above get you everything you want in your life ... because with this attitude you are not gonna learn or earn anything...!!!

Edited by csurfer: n/a

I like it!

@micjan : Congrats you got the code !!! I certainly wish the two smart people above get you everything you want in your life

Especially since both of them answered with terrible non-standard code, which makes the code dangerous to people's understanding of good code practices. Please ignore the code given.

They were horrid excuses for programs weren't they :)

please make a factorial number that the output is like this:

Enter a number:5

5!=1*2*3*4*5
5!=120

likewise

Enter a number:6
6!=1*2*3*4*5*6
6!=720

using for loop statement only.

use this
example:
#include <stdio.h>
#include <conio.h>
........etc.

``````#include<stdio.h>
main()
{
int a, fact;
printf("\nEnter any number: ");
scanf ("%d", &a);
fact=rec (a);
printf("\nFactorial Value = %d", fact);
}

rec (int x)
{
int f;
if (x==1)
return (1);
else
f=x*rec(x-1);
return (f);
}``````