Jump to content

View more

Image of the Day

Inventory ! Va falloir trouver une autre couleur pour le cadre D: #AzTroScreenshot #screenshotsaturday https://t.co/PvxhGL7cOH
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now
- - - - -

About C basics....!

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • This topic is locked This topic is locked
1 reply to this topic

#1 Balanand   Members   

122
Like
0Likes
Like

Posted 27 May 2006 - 06:35 PM

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???

#2 Ravuya   Members   

135
Like
0Likes
Like

Posted 27 May 2006 - 07:56 PM

Please don't cross-post.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.