This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up**This preview shows
pages
1–3. Sign up
to
view the full content.*

Exam 1 COSC140 Review
1. Convert each of the following mathematical formulas to a C++ expression.
3 * x
3 * x+y
(x+y)/7
(3 * x) / (z+y)
x^6
2.
What is the output of the following program lines when they are embedded in a correct
program that declares number to be of type int?
Int number = (1/3) * 3;
(0)
Cout<< “(1/3) * 3
is equal to “ << number;
Output
(1/3) * 3 is equal to 0
3.
Write a 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.
Int Num1;
Int num2;
Cin>>num1;
Cin>>num2;
Cout<<”The whole number part is”<<Num1/num2<<”and the remainder is”<<Num1%Num2;
4.
What statements should you include in your program to ensure that when a number of type
double is output, it will be ouptut in ordinary notation with three digits after the decimal point?
Cout.setf(ios::showpoint);
Cout.setf(ios::fixed);

This
** preview**
has intentionally

Cout.precision(3);
5.
Determine the value, true or false, of each of the following Boolean expressions, assuming
that the value of the variable count is 0 and the value of the variable limit is 10.
Give your
answer as one of the values true or false.
Count =0
Limit = 10
A. (count
==
C. (limit > 20) || (count < 5) T
D. !(count == 12)
T
F. (count < 10) || (x < y) T
G. !( ((count < 10 || (x < y) )&& (count

This is the end of the preview. Sign up
to
access the rest of the document.

Ask a homework question
- tutors are online