Sample program in C++


int main()


return 0;


Now, each and every program begins the Function main(). Every C++ program has a main() function. In general, a Function is a block of code that performs one or more actions.

Furthermore, each and every function begins with an opening brace( { ) and ends with a closing brace ( } ). Also, we consider everything between the opening and closing braces as the Part of the Function.

Certainly, main() is a very special function. Why? Because, usually functions are invoked by other functions.. But, when your program starts, main() is called automatically.

Generally, main() function, like every other function must state what kind of value it return. Furthermore, the return value type in the sample C++ program is int that means main() will return an integer value to the operating system.

Also, the return value type may be void. Void represents that this function will not return any value at all.


cout<<“THIS IS A SAMPLE C++ PROGRAM”<<endl;    

Especially relevant, the file iostream.h (Input-Output-Stream) uses “cout” which assists with writing to the screen. Furthermore, we use the object cout “To print a message to the output screen“.

And, we use the object cout in C++ mostly to print strings and values to the screen. [We can define a string as a collection or a set of characters]

Here’s how we use cout..

  • First of all, Type the word cout, following the output redirection Operator (<<).
  • Secondly, whatever follows the output redirection Operator, prints to the output screen.
  • Furthermore, if you want to print a string of characters.. One should be sure to enclose them in double quotes () , as shown in the sample C++ Program..

Also, endl is a stream manipulator in C++. Furthermore, we use endl for ending the existing line and for the beginning of a new line. Thus, endl ends the existing line and starts the beginning of a new line.

Therefore, this was all about A SAMPLE PROGRAM IN C++..

Also, for more information regarding THE KEY FEATURES IN C++, Click on..



Leave a comment

Your email address will not be published. Required fields are marked *

10 thoughts on “A SAMPLE PROGRAM IN C++”