- cin is used for accepting data from the keyboard/user.
- The operator >> called as extraction operator or get from operator.
- Extraction operator is similar to the scanf() operation in C.
- cin is the object of istream class.
Example of cin :
#include<iostream.h>
#include<conio.h>
void main(){
clrscr();
int n1,n2;
cout<<"Enter 1st Number : ";
cin>>n1; // accept 1st number
cout<<"Enter 2nd Number : ";
cin>>n2; // accept 2nd number
cout<<"Addition = "<<n1+n2; //Display addition of 2 numbers
getch();
}
Output:
For Example: User Enter Numbers
Enter 1st Number : 10
Enter 2nd Number : 20
Addition = 30
No comments:
Post a Comment