CS 150 Introduction to C++ Programming - Spring 1998 

[ Home | Lecture Notes| WebTutor | WebTutor Site Map]


Formatting Output (Exercise 7 Chapter 3)


Given the following program, tell the output of each line that would appear on the standard output stream.

#include <iostream.h>
#include <iomanip.h>
int main()
{
   char ch;
   int n;
   float y;
   ch = 'A';
   cout << ch;
   ch = 'b';
   cout << ch << endl;
   n = 413;
   y = 21.8;
   cout << setw(5) << n << " is n" << endl;
   cout << setw(7) << y << " is y" << endl;
   return 0;
}

There may be less than 5 lines, leave unused lines blank.

  1. line 1

  2. line 2

  3. line 3

  4. line 4

  5. line 5

Choose one when done
   

Copyright chris wild 1998.
For problems or questions regarding this web contact [Dr. Wild (e-mail:wild@cs.odu.edu].
Last updated: February 08, 1998.