-->

WAP to input using cin.

// program to understand cin object in C++
#include<iostream>
#include<stdlib.h>
using namespace std;
int main()
{
    system("cls");  // clears the screen
    int a,b;        //declaration of variables
    cout<<"enter values for a and b"<<endl;
    cin>>a>>b;// multiple inputs using 'get from' operator (>>). we can use in different line.
    cout<<"a="<<a<<" and b="<<b<<endl;// prints input values in same line with string literal. we can use different line.
    return 0;                         // it is also called chaining outputs/inputs
}

No comments:

Post a Comment