Comments are special remarks that helps to understand different parts of the code in C++ program. Comments are ignored by the compiler. In C++,there are two types of comments statement.
Single line Comment
Multi line Comment
SINGLE LINE COMMENT
This type is used to write single line comment. Double slash (//) symbol of each single line comment. is used at the start
Example:
// This is my first C++ program
// This program displays a statement on screen
#include<iostream>
int main()
{
puts(“My First C++ Program”);
return 0;
}
MULTI LINE COMMENT
This type is used to write multi line comment. Symbols (/* and */) are used at the start and end of comment statements.
Example:
/* This is my first C++ program
This program displays a statement on screen */
#include<iostream>
int main()
{
puts(“My First C++ Program”);
return 0;
}
INPUT/OUTPUT STATEMENTS IN C++
Input and output statements are used to perform input & output operations in C++. These input / output statements are stored in header files like <iostream>. At the beginning of every program these header files must be included.
INPUT/OUTPUT STATEMENTS IN C++
cout STATEMENT
cout stands for “Character Output”. In C++, cout sends formatted output to standard output devices, such as the screen. cout object is used along with the insertion operator (<<) for displaying output.
syntax
cont << variable; or cont << exp. / string;
Example:
cont << “This is C++ Programming”;
cont << num1;
puts() STATEMENT
This function is used to print the string output. After printing the screen new line is automatically inserted.
syntax
puts(“string constant”);
Example:
puts(“This is C++ Programming”);
Quiz
Time limit: 0
Quiz Summary
0 of 8 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.