Monday, June 18, 2012

Homework 2: Output

1. Given an integer variable count, write a statement that writes the value of count to standard output.

cout << count;

2. Given a floating-point variable  fraction , write a statement that writes the value of  fraction to standard output.

 Do not write anything else to standard output -- just the value of  fraction .

cout << fraction ;

3. Given an integer variable i and a floating-point variable f, write a statement that writes both of their values to standard output in the following format: i=value-of-i f=value-of-f

 Thus, if i has the value 25 and f has the value 12.34, the output would be:

i=25 f=12.34

 But if i has the value 187 and f has the value 24.06, the output would be:

i=187 f=24.06

Instructor's notes: Don't forget to output a space between i=value-of-i and  f=value-of-f


cout << "i=" << i << "`f=" << f ;

No comments:

Post a Comment