English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Themain()
Functions are global functions. Used to start the execution of the program. Every program should havemain()
. The command line arguments argc and argv are optional.
main()
The standard prototype of the method is as follows.
int main(){ body } OR int main(int argc, char *argv[]) { body }
Here,
argc-The number of arguments passed from the environment to the program.
argv-Pointer to the first element of the array.
The following is an example main()
#include <iostream> using namespace std; int sum(int x, int y) { int s = x + y; cout << "The sum of numbers: " << s; } int main() { sum(28, 8); return 0; }
Output result
The sum of numbers: 36
In the above program, this code exists insum()
Calculate the sum of two numbers.
int sum(int x, int y) { int s = x + y; cout << "The sum of numbers: " << s; }
Themain()
The method is being calledsum()
sum(28, 8);