C++ comes with libraries which helps us in performing input/output.
In C++ Sequence of bytes corresponding to input and output are commonly known as "STREAM"
Input Stream - Direction of flow of bytes takes place from device to main memory. and cin is a predefined variable that reads data from the keyboard with the extraction operator (>>).
Output Stream- Direction of flow of bytes take place from main memory to device. and cout is predefined varible that displays data with insertion operator (<<).
A Simple Input/output program and add two numbers:
#include<iostream>
using namespace std;
int main()
{
int num1,num2;
cout<<"Enter num1 value:"<<endl;
cin>>num1;
cout<<"Enter num2 value:"<<endl;
cin>>num2;
cout<<"Sum of num1 and num2 is:"<<num1+num2<<endl;
return 0;
}
Output:
Enter num1 value: 10
Enter num2 value: 20
Sum of num1 and num2 is: 30
AUTHOR : Rakshit Joshi [ Linkedin Profile ]
For Videos Join Our Youtube Channel: Join Now