English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
main()
The return value of the function shows how the program exits. The normal exit of the program is represented by a return value of zero. If there are errors, faults, etc., it will terminate with a non-zero value.
In C ++In the language, themain()
Functions can be retained without returning a value. By default, it will return zero.
This ismain()
The syntax of functions in C language
int main() { ... return 0; }
This ismain()
Function example in C language
#include <stdio.h> int main() { int a = 10; char b = 'S'; float c = 2.88; a = a+b; printf("Implicit conversion from character to integer: %d\n", a); c = c+a; printf("Implicit conversion from integer to float: %f\n", c); return 0; }
Output result
Implicit conversion from character to integer: 93 Implicit conversion from integer to float: 95.879997
In the above program, the main function contains the business logic. There are three variables a, b, and c, where a keeps the sum of a and b. Variable c contains the sum of c and a. The main function returns 0.
a = a+b; printf("Implicit conversion from character to integer: %d\n", a); c = c+a; printf("Implicit conversion from integer to float: %f\n", c); return 0;