Professional Documents
Culture Documents
Amer Al-Badarneh)
1.
____ the algorithm refers to the process of translating the algorithm into a language that the
computer can understand.
a.
Assembling
b.
2.
a.
desk-checking
3.
a.
b.
Tracing
c.
running
Translating
d.
Coding
d.
compiling
c.
hand-tracing
b.
c.
d.
4.
a.
b.
translate the program code from high level language to machine language
c.
5.
a.
b.
c.
d.
6.
The statement ____ tells the computer to get the current weekly pay from the keyboard, and store
d.
a and b
b.
c.
d.
7.
double y;
x= 4;
y=5;
cout<<x+y<<endl;
}
a.
b.
c.
9.00
d.
9.0
8.
a.
const
9.
a.
7_bottles
10.
b.
long
b.
c.
if
_7_Bottles
d.
c.
Return
seven_bottles
d.
_Bott
26.3
b.
22
11.
c.
22.3
d.
24
12.
a.
b.
c.
d.
13.
a.
b.
c.
d.
14.
a.
7edu = edu +1
b.
edu +7 = edu
c.
edu *= edu +7
d.
edu =* edu +7
15.
a.
-4
16.
a.
b.
30
c.
18
27
cout<<(4 % 2 * 6 / 3 - 5 + (7/4)); ?
b.
-3.25
c.
//line #1
x++;
//line #2
cout<<x<<endl;
//line #3
b.
d.
c.
-3
d.
d.
17.
a.
b.
c.
d.
18.
value += sum++;
sum = sum + 1;
int i = 1, j = 2, k = 3;
cout << i + static_cast<double>(5 % (j + 2)) / k << endl;
a.
b.
1.33333
c.
19.
a.
b.
c.
"repeat 20 times"
d.
20.
x%10 > 9
a.
b.
c.
It is always false
21.
The statement that compares the value of an integer called sum against the value 65, and if it is less,
d.
d.
0.33333
It is always true
b.
c.
if (65 == sum)
d.
22.
The statement that compares total for equality to good_guess, and if equal prints the value of
total, and if not equal prints the value of good_guess, is
a.
if (total < good_guess) cout << total; else cout << good_guess;
b.
c.
d.
23.
Consider the following C++ code. How much is added to premiumDue if driverAge is 22 and
numTickets is 0?
if(driverAge < 26)
premiumDue += 100;
premiumDue -= 50;
if(numTickets == 2)
premiumDue += 60.25;
a.
-50
b.
10.25
c.
24.
60.25
d.
100
if(department == 1 || 2) cout<<"Yes";
a.
When department is 1
b.
When department is 1 or 2
c.
Always
d.
Never
25.
"<<y<<endl;
cout<<"It is False"<<endl;
a.
5 9
b.
5 8
c.
5 7
d.
It is False
26.
a.
b.
if ( !(num == 65))
c.
if (num 65)
d.
if ( !(num 65))
27.
a.
76
b.
35
28.
c.
635
d.
7635
d.
Nothing
OK
b.
Cancel
c.
OK Cancel
29.
Consider the following pseudo code. If the sales amount is 15000, the value of the bonus amount at
the end of the algorithm will be ____.
1. enter sales amount
2. calculate the bonus amount by multiplying the sales amount by .08
3. if (the sales are greater than or equal to 10000)
else
720
b.
845
c.
1200
d.
1350
30.
Write a program that prompts the user to input a number. The program should then output the
number and a message saying whether the number is positive, negative, or zero.
#include <iostream>
using namespace std;
void main(){
int number;
cout << " Enter a number<<endl;
cin >> number;
cout << "The number "<< number;
if ( number > 0 ) cout << " is positive" << endl;
if ( number < 0 ) cout << " is negative" << endl;
if ( number == 0 ) cout << " is zero" << endl;
}
31.
Write a program that prompts the user to input a number. The program should then output the
number and a message saying whether the number is even, odd, or zero.
#include <iostream>
using namespace std;
void main(){
int number;
cout << " Enter a number<<endl;
cin >> number;
cout << "The number "<< number;
if ( number % 2 == 0 ) cout << " is Even" << endl;
if ( number % 2 !=
if ( number == 0 )
}
32.
Find the errors in the following program? Re-write the code making it free from syntax errors.
Line1:
include <iostream>
// missing #
int main(
// missing );
{
Line3:
int x;
Line4:
Line5:
cin > x;
// missing >
Line6:
x = 5 - 3
// missing ;
Line7:
return 0;
33.
Find the errors in the following program? Re-write the code making it free from syntax errors.
Line1: #include <iostream>
Line2: using namespace std;
Line3: int mian() {
Line4:
// remove const or
Line5:
int x;
Line6:
x = ch;
Line7:
y = x++
Line8:
ch = 'B';
Line9:
cout << "x: " << x << "\ty: " << y << "\tch: " << ch;
Line10:
}
return 0;
// missing ;
// assign to a constant identifier