

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
C++ programming examples for various input and output statements, including getting user input, reading delimited strings, flushing output, and formatting output with precision.
Typology: Lecture notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!
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.