CS 150 Introduction to C++ Programming - Spring 1998 

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


Standard Integer Input (Exercise 2 Chapter 4)


Standard input is extracted cin, the standard input stream using the extraction operator (>>).
When inputting a number, the extraction operator will "search" for the number by skipping over any leading whitespace (blanks and end of lines).
Input stops when an inappropriate character for that number type is found.
Thus >> reads only as many characters from cin as are needed to form a number.
Any characters after the number (including the character that stopped the input) are still available for the next input operation.

(see pages 133-138 in the textbook).

Given two lines of input (that you may type in on the keyboard):

17 13
7 3 24 6

and the following input statements (where all the variables are of type int)

	cin >> int1 >> int2 >> int3;
	cin >> int4;

What is the value of the following?

  1. int1

  2. int2

  3. int3

  4. int4

 

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: March 08, 1998.