Welcome back! In my last post, I tell you about C tokens after that we need to know about Function that is very important in C/C++ language, so let's start....
Every C program consists of one or more functions. One of these functions must be called main. Execution of the program will always beign by carrying-out the instructions in main. Additional functions will be subordinate to main, and perhaps to one another.
Generally, a function will process information that is passed to it from the calling portion of the program, and return a single value.
Information is passed to the function via special identifiers called arguments(also called parameters), and returned via the return statement. Some functions, however, accept information but do not return anything(of type void), whereas other functions return multiple values, with help of pointers and arguments(e.g., library function scanf).
Body of a function:
- The general structure of the general function is:
Functiontype FunctionName
{
Statement 1;
Statement 2;
}
- The function body is the bit between the opening and closing braces that the line where the function name appears. The fuction body contains all the statements that define what the function does.
{ /*This marks the beginning of main()*/
printf("Hello"); /*This line displays a quotation*/
return 0; /*This returns control to the operating system*/
} /*This marks the end of main()*/
0 comments:
Post a Comment