/*factirial*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n,s=1,i;
clrscr();
printf("enter n ");
for(i=1;i<n;i++)
{
scanf("%d",&n);
}
for(i=1;i<n;i++)
{
s=s*i;
}
printf("factorial is %d",s);
getch();
}
ajay kandari
0
Newbie Poster
Recommended Answers
Jump to Postand is there a logical problem with your code...?
By the way, main should return a type int ;)
Jump to Post/*factirial*/ #include<stdio.h> #include<conio.h> void main() { int n,s=1,i; /* n = unknown garbage, s = 1, i = unknown garbage */ clrscr(); printf("enter n "); for(i=1;i<n;i++) /* Initially loop as long as i is less than n. what was in n?. Garbage! anything can happens */ { …
Jump to PostAia, what did you just post? No explanation, no formatting, improper programming practices (
void main()
,getch()
,clrscr()
)
You should model good practices and proper techniques. You seem to have been here long enough to know this... ;)
Jump to PostAia, what did you just post? No explanation, no formatting, improper programming practices (void main(), getch(), clrscr())
You should model good practices and proper techniques. You seem to have been here long enough to know this... ;)@WaltP
I just tried to expose the logic of his code using …
All 16 Replies
Infarction
503
Posting Virtuoso
Aia
1,977
Nearly a Posting Maven
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
Aia
1,977
Nearly a Posting Maven
John A
1,896
Vampirical Lurker
Team Colleague
ajay kandari
0
Newbie Poster
ajay kandari
0
Newbie Poster
ajay kandari
0
Newbie Poster
ajay kandari
0
Newbie Poster
Aia
1,977
Nearly a Posting Maven
Aia
1,977
Nearly a Posting Maven
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
Salem
5,138
Posting Sage
ajay kandari
0
Newbie Poster
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
Salem
5,138
Posting Sage
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.