Preview
cout statement in C++ | Display output in C++
cout stands for console output. cout statement in C++ is used to display value of a variable or a literal. cout statement is an instance of ostream class.
It is followed by insertion operator (<<) followed by a variable or a literal that you want to display.
The header file required to use cout is <iostream>. You also need to import std namespace in the program as:
using namespace std;
Syntax:
cout<<val;
Here, val refers to a variable or literal whose value you want to display.
//Program to demonstrate the use of cout statement in C++.
#include<iostream> using namespace std; int main() { int val; cout<<"Enter a value="; cin>>val; cout<<"val="<<val; return 0; }
Output
Enter value of num=10 a=10
Popular Books of Computer Science