Sample C++ Program
// comment Statement
#include
#include
main()
{
cout<<"God";
}
Output will be
God
Main()
The C++ program is a collection of functions. Every C++ program must have a main()
Comment Statemen
Two type of comments are there
1. Single line comments
2. Multi line comments
C++ introduces a new comment symbol // (Double slash).
Single line comments
Double slash comment is basically a single line comment. Start with double slash symbol and terminate at the end of the line. A comment may start anywhere in the line and whatever follows till the end of the line is ignored. Note that there is no closing symbol.
Single line comments can be written as follows:
//cout<<”Good Morning”; //cout<<”Good Afternoon”; //cout<<”Good Evening”; //cout<<”Good Night”;
Multi Line comments
The comment symbols /*, */ are still valid and are more suitable for multi line comments. Multi line comments can be written as follows:
/* cout<<”Good Morning”; cout<<”Good Afternoon”; cout<<”Good Evening”; cout<<”Good Night”; */
Example
For example, the double slash comment cannot be used in the following case:
for (j=0; j
No comments:
Post a Comment