• Advertisement
Sign in to follow this  

About C basics....!

This topic is 4253 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hallo every body. I am a beginer in the field of programing and hence asking here a very basic problem in C language. Please forgive me if this question looks you to be stupid. Here is my problem... Any function returns a value to another function which have called it, eg. Look at the following simple program- main() { int a, fact; printf("\nEnter any number"); scanf("%d",&a); fact= factorial(a); printf("Factorial Value= %d", fact); } factorial(int x) { int f=1, i; for(i=x;i>=1;i--) f= f*i; return(f); } In this program, We have used a user defined function 'factorial'. The statement 'return(f)' tells the compiler to return the value of variable 'f' to the function 'main'. 'main' is also a function, which also must return a value to something. This is my question that to whom the function 'main' returns value. If it is the O/S, then what the O/S does with this value? Further, we use a keyword 'void' before the function 'main' to tell the compiler to not to return any value by the function 'main'. What does this all mean???

Share this post


Link to post
Share on other sites
Advertisement

This topic is 4253 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement