Docsity

C++ Programming: Input and Output Statements, Lecture notes of Computer Programming

Toggle sidebar
bg1
For each of the following, write a single statement that performs the
indicated task.
Question 1
Output the string “ Enter your name”
Question 2
Input a single character into variable c of type char using the istream
member function get in two ways.
Question 3
Read 10 characters into character array name. Stop reading characters if the
‘.’ delimiter is encountered. Do not remove the delimiter from the input
stream.Write another statement that performs this task and removes the
delimiter from the input.
Question 4
Write separate statements to flush the output stream using a member
function and a stream manipulator.
Question 5
Output the following values: 124, 18.376, ‘Z’, 1000000 and “String”.
pf2

Partial preview of the text

Download C++ Programming: Input and Output Statements and more Lecture notes Computer Programming in PDF only on Docsity!

For each of the following, write a single statement that performs the indicated task.

Question 1 Output the string “ Enter your name”

Question 2 Input a single character into variable c of type char using the istream member function get in two ways.

Question 3 Read 10 characters into character array name. Stop reading characters if the ‘.’ delimiter is encountered. Do not remove the delimiter from the input stream.Write another statement that performs this task and removes the delimiter from the input.

Question 4 Write separate statements to flush the output stream using a member function and a stream manipulator.

Question 5 Output the following values: 124, 18.376, ‘Z’, 1000000 and “String”.

Question 6 Input an integer value into int variable months and a floating-point value into float variable percentageRate.

Question 7 Print 1.92, 1.925 and 1.9258 with 3 digits of precision using manipulator.

Question 8 Print 1234 right-justified in a 10-digit field.

Question 9 Read characters into character array line until the character ‘z’ is encountered up to a limit of 20 characters ( including a terminating null character). Do not extract the delimiter character from the stream.

Question 10 Using integer variable x and y to specify the field width and precision used to display the double value 87.4573.