logo

Crowdly

In C++ we read characters from the keyboard using global variable std::cin tha...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

In C++ we read characters from the keyboard using global variable std::cin that encapsulates the standard input stream and is of a C++ standard library type std::istream. Here, std::cin is the fully qualified name of object cin that is defined in namespace std.

Both C and C++ define bitwise right shift binary operator >> with the syntax

lhs-integral-expression >> rhs-integral-expression

to shift the bits of left operand lhs-integral-expression to the right by the number of bits in right operand rhs-integral-expression.

Class type std::istream overloads bitwise right shift operator >> to read characters representing different types of values from an input stream. Format specification, which is the first parameter of function scanf is not required. Using overloaded operator >> instead of function scanf also allows us to read multiple values from the input stream in a single chained statement, as in the following example:

int x;

double y;

std::cin >> x >> y;

Supposing the user types characters into the standard input stream, write the exact text written by the following code fragment to the standard output stream.

int x;

double y;

std::cin >> x >> y;

std::cout << x+static_cast<int>(y);

More questions like this

Want instant access to all verified answers on distance3.sg.digipen.edu?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome