Concept explainers
Assume the following variables are defined:
int age;
double pay;
char section;
Write a single cin statement that will read input into each of these variables.
Explanation of Solution
“cin” statement:
“cin” is the standard input stream that is used together with the extraction operator “>>” to process the formatted input.
Syntax:
Syntax to read input by using “cin” statement:
cin >> variable1 >> variable2;
- In the above statement, “cin” is a predefined keyword and “variable” is the name of the variable to read value from the user.
Single “cin” statement to read input:
/* input statement to get three input using single line */
cin >> age >> pay >> section;
The above statement is used to get three inputs “age”, “pay” and “section” from the user by using a single “cin” statement.
Want to see more full solutions like this?
Chapter 3 Solutions
Mylab Programming With Pearson Etext -- Access Card -- For Starting Out With C++: From Control Structures Through Objects, Brief Version
Additional Engineering Textbook Solutions
Starting Out with Java: Early Objects (6th Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
Concepts of Programming Languages (11th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
C How to Program (8th Edition)
Introduction To Programming Using Visual Basic (11th Edition)