Use of cout and cin in C++ Programming Language - console output and console input - learn C++

 

Use of cout and cin in C++ Programming Language - console output and console input - learn C++

Cout: 

"cout" refers to the standard output (or Console OUTput). The symbol << is called the stream insertion operator (or put - to operator ), which is used to put the string "hello, world" to the console. "endl" denotes the END-of-Line or newline. 

cin:

  • cin is used to take the input from user.
  • We then use "cin >> nameOfTheVariable" to read the user input from the keyboard and store the value into variable .
  • cin is known as the standard input device (or Console INput), i.e., keyboard
  • >> is known as stream extraction operator. The operator must be followed by a variable.

Example of cout and cin:

#include <iostream>     // std::cout, std::endl

using namespace std;

int main () {

int number;

cout<<"enter any number"<<endl; //cout

cin>>number;  //cin

cout<<"you have entered "<<number;  //cout

return 0;

}

Use of cout and cin in C++ Programming Language - console output and console input - learn C++
Use of cout and cin in C++ Programming Language - console output and console input - learn C++

Output:
Use of cout and cin in C++ Programming Language - console output and console input - learn C++
Use of cout and cin in C++ Programming Language - console output and console input - learn C++



Post a Comment

0 Comments