Write a driver program to perform each of the following: a) Print integer 40000
ID: 3768235 • Letter: W
Question
Write a driver program to perform each of the following:
a) Print integer 40000 left justified in a 15-digit field.
b) Read a sentence into character array variable state, and print it out.
c) Print 200 with and without a sign, and with from 0 – 10 decimal digits.
d) Print the decimal value 100 in hexadecimal form preceded by 0x, and in octal form preceded by 0.
e) Read characters into array charArray until the character 'p' is encountered, up to a limit of 10 characters (including the terminating null character). Extract the delimiter from the input stream, and discard it. Print out the content of the charArray one by one, set the width = 15 and following by a new line.
f) Print 1.234 in a 9-digit field with preceding zeros
Explanation / Answer
#include 02 #include 03 #include 04 using std::string; 05 using std::cout; 06 using std::endl; 07 using std::cin; 08 using std::left; 09 using std::setw; 10 using std::setprecision; 11 using std::showpoint; 12 using std::showpos; 13 using std::noshowpos; 14 using std::hex; 15 using std::showbase; 16 using std::skipws; 17 18 void main(){ 19 20 //print integer 40000 left justified in a 15-digit field 21 coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.