Professional Documents
Culture Documents
Test 1 MEMO
03 March 2016
90 minutes
StudNo:
a. false
c. true
b. 0
d. null
a. 150
c. 160
2. Suppose that x is an int variable. Which of the
following expressions always evaluates to true?
a. (x >0) &&(x <= 0)
c. (x >=0)||(x==0)
b. (x >0)||(x <= 0)
d. (x>0)&&(x == 0)
b. 155
d. 165
10 11
3. What is the output of the following C++ code?
int x =
int y =
int z;
if (x >
z =
else
z =
cout <<
<<
35;
45;
y)
x + y;
y x;
x << " " << y << " "
z << endl;
35 45 10
4. Which, if any, of the following will cause a syntax
error if you are attempting to compare x to 5?
a. if (x == 5)
c. if (x = 5)
b. if (x >= 5)
d. none of these
b. using
d. namespace
11. Which of the following statements declares the 14. Which of the following class definitions is correct in
studentGrade variable?
C++?
a. enum studentGrade {A, B, C, D, F};
a. class studentType
b. enum int {A, B, C, D, F} studentGrade;
{ public:
c. enum studentGrade {A, B, C, D, F}
grades;
d. enum grades {A, B, C, D, F}
studentGrade;
b. class studentType
{ public:
void setData(string, double, int);
void print() const;
private:
string name;
double gpa;
}
c. class studentType
{ public
void setData(string, double, int);
private string name;
};
d. studentType class
{
public:
void setData(string, double, int);
private: string name;
};
15.
a. bigRect.setLengthWidth();
b. bigRect.setLengthWidth(3.0,2.0);
c. bigRect.length = 14.0;
c. bigRect.print();
d. bigRect::print();
b. automatic
c. local
d. public
Illegal
c) p = &x;
d) p = &*&y;
e) x = &*q;
Legal
Legal
Illegal
g) p = &*q;
Legal
Legal
h) q = **&p;
Illegal
Legal
(b) Function indexHighTemp: This function determines and returns the index of the highest high temperature
for the year.
(6)