Beruflich Dokumente
Kultur Dokumente
5.
int a, b, s;
a = 5;
b = 4;
s = a + b;
cout << The sum of;
cout << a << and <<b;
cout << is << s << \n;
II.
Ffloat x, y, p;
Xx = 5.31;
Yy = 7.87;
Pp = x * y;
cout << The product of \n << x << and;
cout << y << is\n << p;
Write a complete C++ program that reads two whole numbers into two variables of type int,
and then outputs both the whole number part and the remainder when the first number is
divided by the second.
6. Given the following fragment the purports to convert from degrees Celsius to degrees
Fahrenheit, answer the following questions:
double c = 20;
double f;
f = (9/5) * c + 32.0;
I.
What value is assigned to f?
II.
Explain what is actually happening, and what the programmer likely wanted.
III.
Rewrite the code as the programmer intended.
Department of Statistics and Computer Science
University of Sri Jayewardenepura