Site icon TestingDocs.com

C++ Output Statement

Overview

In this tutorial, we will learn the C++ output statement with the help of a sample program. The basic output object to display output to the standard output device is the cout object.

C++ Output Statement

We use the cout output object and the << operator to display the output to the standard output device. The C++ standard output device is the monitor.

For example, to display a string, we can use the following statement

cout << “Hello World!”;

C++ Program

We will write a simple C++ program to understand the concept. We will write a simple program to display output to the standard output device i.e monitor screen.

/************************************
* C++ Output
* Filename: output.cpp
* Program to display output to standard
* output device i.e monitor screen.
* C++ Tutorials – www.TestingDocs.com
**************************************/
#include
using namespace std;
int main()
{
int num; //declare integer variable
cout << “Enter integer input:”; // User prompt
cin >> num; // C++ Input Statement
cout << “The value is =:” << num << endl;

return 0;
} // end main

Sample Output

Enter integer input:79
The value is =:79

 

C++ Tutorials

C++ Tutorials on this website:

https://www.testingdocs.com/c-coding-tutorials/

For more information on the current ISO C++ standard

https://isocpp.org/std/the-standard

 

Exit mobile version