Basic input/output in C++

‘cin’ is used to take input from keyboard and ‘cout’ is used to display output on the screen. ‘iostream’ which stands for input-output stream is a  header file which contains ‘cin’ and ‘cout’. A string can be printed on the output screen using ‘cout’ and placing inside quotation marks ” “.

#include<iostream>
using namespace std;

int main() {

    int a,b;

    cout<<"Enter two numbers ";
    cin>>a>>b;
    cout<<"Two numbers are "<<a<<endl<<b;

    return 0; 

}

Output:

Enter two numbers 8
5
Two numbers are 8
5
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments