Multiple integer inputs without extraction chaining
Taking more than one integer input without chaining of io extraction operator >>
Learning Objectives
- More than one value collection using successive use of cin object.
- Using expressions within the cout chain of insertion operators.
Source Code
|
Run Output
Code Understanding
int a,b;
Here two integer variables are declared without initilisation. We may not give an initial value as it will soon be given by the user using the cin.
cout<<“Enter an integer number: “;
cin>>a;
Prompt to input first value followed by value collection using cin.
cout<<“Enter another integer number: “;
cin>>b;
Prompt to input second value followed by value collection using cin.
cout<<“Sum of two entries “<<a+b<<endl;
Here both the collected values are being added within the cout expression formation.
Suggested Filename(s): intinput2.cpp, input2.cpp, inputwoc.cpp
CSKC| Created: 14-Dec-2017 | Updated: 31-Aug-2018|