C++: First Program


Here is the first program that I have wrote .

#include<iostream>
int main()
{
int age;
std::cout<<“What is your age”;
std::cin>>age;
std::cout << “Your age is “<< age;
return 0;
}

<iostream> is the input output library ,without which we can not do input and output operation in the c++;

#include is a processor directive ,which loads the predefined libraries and files to the source code. Some other commonly used processors are – #if, #elif, #else, #endif

std::cout – standard output operation, << sign is used for the output operation.
std::cin -standard input operation, >> sign is used for the input operation.

Main Function:

Every C++ function must have one main() function. When the C++ codes get executed, the main() function is called by the operating system and the code within that main() function gets executed.
When the return statement return 0, then the program stops execution.
There is another type of main function ie.

main(int arg, char *argvalue[ ] )
{
//write code here.
return 0;
}

Here the arguments are passed to the main function arg as integer and argument as array-value.