Here is an example of a complete C++ program:
// The C++ compiler ignores comments which start with // double slashes like this, up to the end of the line.

/* Comments can also be written starting with a slash followed by a star, and ending with a star followed by
a slash. As you can see, comments written in this way  can span more than one line. */

/* Programs should ALWAYS include plenty of comments! */

/* Author: Rob Miller and William Knottenbelt Program last changed: 30th September 2001 */

/* This program prompts the user for the current year, the user’s current age, and another year. It then calculates the age that the user was or will be in the second year entered. */

#include<iostream>

using namespace std;
{
cout<<” c++ is better than c \n”;
return 0;
}

Input Operator cin :-
The identifier cin is a predefined object in c++ that corresponds to the standard input stream. Here this stream represents keyboard. Syntax:- cin>>variable; The operator >> is known as extraction or get from operator & assigns it to the variable on its right.

2. Output operator cout :-
The identifier cout is predefined object that represents the standard output stream in c++. Here standard output stream represents the screen. Syntax:- cout<<string; The operator << is called the insertion or put to operator. It inserts the contents of the variable on its right to the object on its left.

3. Return type of main():-
In C++, main returns an integer type value to the operating system. So return type for main() is explicitly specified as int.Therefore every main( ) in c++ should end with a return 0 statement

Share with : Share on Linkedin Share on Twitter Share on WhatsApp Share on Facebook