Topic 4| User input/output, Comments
Input Output and Comments in C++
User input in C++
Output in C++
New line in C++
Comments in C++
Coding examples
1
, Topic 4| User input/output, Comments
User input in C++:
Any information or data sent to a computer for processing is considered input.
Cin is a predefined variable that is used to read the input from the user.
For example:
cin >> name;
cin >> age >> roll num;
>> is used with cin.
Output in C++:
Any information that is processed by and sent out from a computer or other electronic device is
considered output. Cout is a predefined variable that is used to output values/print text.
For example:
Cout<< name;
Cout<< "My name is " << name;
<< is used with cout.
New line in C++:
When we want to print different outputs in separate lines, we use "\n".
For example:
cout << "Hello!\n ";
cout << "My name is Waleed";
Another way to insert a new line, is by using endl .
For example:
cout << "Hello!" << endl;
cout << "My name is Waleed";
C++ statement must end with a semicolon (;).
2
Input Output and Comments in C++
User input in C++
Output in C++
New line in C++
Comments in C++
Coding examples
1
, Topic 4| User input/output, Comments
User input in C++:
Any information or data sent to a computer for processing is considered input.
Cin is a predefined variable that is used to read the input from the user.
For example:
cin >> name;
cin >> age >> roll num;
>> is used with cin.
Output in C++:
Any information that is processed by and sent out from a computer or other electronic device is
considered output. Cout is a predefined variable that is used to output values/print text.
For example:
Cout<< name;
Cout<< "My name is " << name;
<< is used with cout.
New line in C++:
When we want to print different outputs in separate lines, we use "\n".
For example:
cout << "Hello!\n ";
cout << "My name is Waleed";
Another way to insert a new line, is by using endl .
For example:
cout << "Hello!" << endl;
cout << "My name is Waleed";
C++ statement must end with a semicolon (;).
2