Chapter 3.1 - The cin Object C++

Chapter 3.1 - The cin Object C++

memorize.aimemorize.ai (lvl 286)
Section 1

Preview this deck

Assume that name has been declared suitably for storing names (like "Misha", "Emily" and "Sofia") Write some code that reads a value into name then prints the message "Greetings, NAME " where NAME is replaced the value that was read into name . For example, if your code read in "Rachel" it would print out "Greetings, Rachel".

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (9)

Section 1

(9 cards)

Assume that name has been declared suitably for storing names (like "Misha", "Emily" and "Sofia") Write some code that reads a value into name then prints the message "Greetings, NAME " where NAME is replaced the value that was read into name . For example, if your code read in "Rachel" it would print out "Greetings, Rachel".

Front

cin >> name; cout << "Greetings, " << name << endl;

Back

Given an int variable datum that has already been declared , write a statement that reads an integer value from standard input into this variable .

Front

cin >> datum;

Back

Write a statement that reads an integer value from standard input into val. Assume that val has already been declared as an int variable .

Front

cin >> val;

Back

Write an expression that attempts to read a double value from standard input and store it in an double variable , x, that has already been declared .

Front

cin >> x;

Back

Write a statement that reads a floating point (real) value from standard input into temperature. Assume that temperature. has already been declared as an double variable .

Front

cin >> temperature;

Back

Write an expression that attempts to read an integer from standard input and store it in an int variable , x, that has already been declared .

Front

cin >> x;

Back

Assume that name and age have been declared suitably for storing names (like "Abdullah", "Alexandra" and "Zoe") and ages respectively. Write some code that reads in a name and an age and then prints the message "The age of NAME is AGE." where NAME and AGE are replaced by the values read in for the variables name and age. For example, if your code read in "Rohit" and 70 then it would print out "The age of Rohit is 70.".

Front

cin >> name; cin >> age; cout << "The age of " << name << " is " << age << ".";

Back

Declare k, d, and s so that they can store an integer , a real number, and a small word (under 10 characters ). Use these variables to first read in an integer , a real number, and a small word and print them out in reverse order (i.e., the word, the real, and then the integer ) all on the same line, separated by EXACTLY one space from each other. Then, on a second line, print them out in the original order (the integer , the real, and the word), separated again by EXACTLY one space from each other.

Front

int k; double d; string s; cin >> k; cin >> d; cin >> s; cout << s << " " << d << " " << k << endl; cout << k << " " << d << " " << s << endl;

Back

Assume that name has been declared suitably for storing names (like "Amy", "Fritz" and "Moustafa") Write some code that reads a value into name then prints the message "Greetings, NAME !!!" where NAME is replaced the value that was read into name . For example, if your code read in "Hassan" it would print out "Greetings, Hassan!!!".

Front

cin >> name; cout << "Greetings, "; cout << name << "!!!";

Back