Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi everyone,
I am a high school student and will take c programming later on.
Please tell me:
1. what is the meaning of "return 0;"? When will use it?2. How to declare a variable that stores only positive integer values?
Regards,
Moldman

Typically, return 0 is used to terminate the main function of a C program - after having initialized it as int main(int argc, char argv)
This is done so that you can pass parameters into the program, and to return values from the program. Typically, a return value of 0 means that the program finished correctly, and 1 (or any other integer value) means the the program finished with an error.
To store only integer values in a variable it must be declared as unsigned. All the major numerical data types can be declared as unsigned; short, int, long, etc...
Hope this helps, GL with the class.

Sorry, I need to clarify my first answer.
When I said: "To store only integer values in a variable it must be declared as unsigned. All the major numerical data types can be declared as unsigned; short, int, long, etc..."
I SHOULD have said: "To store only POSITIVE values in a variable it must be declared as unsigned. All the major numerical data types can be declared as unsigned; short, int, long, etc..."

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |