C++ - Cin .

In this session i have discussed the cin in C++ .


cin>>x

The cin is an object of the standard input stream . This >> symbol is called the extraction operator or get from operator . It is used to take the value from keyboard and assign the value in variable . The whole statement take the input from keyboard and assign the value to variable x . We will discuss later in details .

The cin work like scanf() function in C . But cin is not a function .


Example : Write a program that take input from user and print on to screen .

    #include<iostream.h>
    using namespace std;
    int main()
    {
        int a;
        cout<<"Enter the value";
        cin>>a;
        cout<<a;
        return 0;
    }
    
    OUTPUT : Enter the value : 10
             10
    

Welcome to AndroidATPoint.

back image                     next image