C++
Question #1
What number of digits that can be accuratly stored in a float (based on the
IEEE Standard 754)?
a) 6
b) 38
c) An unlimited number
Answer: A
Question #2
Which of the following is evaluated first:
a) &&
b) ||
c) !
Answer: C
Question #3
What does 7/9*9 equal (in C and C++)?
a) 1
b) 0.08642
c) 0
Answer: C
Question #4
Which is not valid in C?
a) class aClass{public:int x;};
b) /* A comment */
c) char x=12;
Answer: A
Question #5
Which of the following is not a valid declaration for main()?
a) int main()
b) int main(int argc, char *argv[])
c) They both work
Answer: C
Question #6
Evaluate as true or false: !(1 &&0 || !1)
a) True
b) False
c) Invalid statement
Answer: A
Question #7
Which command properly allocates memory?
a) char *a=new char[20];
b) char a=new char[20];
c) char a=new char(20.0);
Answer: A
Question #8
What operator is used to access a struct through a pointer?
a) ->
b) >>
c) *
Answer: C
Question #9
Which is not an ANSII C++ function?
a) sin()
b) kbhit()
c) tmpnam()
Answer: B
Question #10
True or false, if you keep incrementing a variable, it will become negative?
a) True
b) False
c) It depends...
Answer: C
Question #11
What character terminates all character array strings
a) \0
b) .
c) \END
Answer: A
Question #12
If you push the numbers (in order) 1, 3, and 5 onto a stack, which pops
out first?
a) 5
b) 1
c) 3
Answer: A
Question #13
What does strcat(an_array, "This"); do?
a) Copies "This" into an_array
b) Adds "This" to the end of an_array
c) Compares an_array and "This"
Answer: B
Question #14
Evaluate:
int fn(int v)
{
if(v==1 || v==0)
return 1;
if(v%2==0)
return fn(v/2)+2;
else
return fn(v-1)+3;
}
for fn(7);
a) 10
b) 11
c) 1
Answer: B
Question #15
Evalute the following: 22%5
a) 2
b) 4
c) 0
Answer: A
Question #16
Which of the following data structures is on average the fastest for
retrieving data?
a) Binary Tree
b) Hash Table
c) Stack
Answer: B
Question #17
What is the output:
int v()
{
int m=0;
return m++;
}
int main()
{
cout<<v();
}
a) 1
b) 0
c) Program is illegal
Answer: B
Question #18
What does cout<<(0==0) print out?
a) 0
b) 1
c) Compiler error: Lvalue required
Answer: B
Question #19
What is the maximum value of a unsigned char?
a) 255
b) 256
c) 128
Answer: A
Question #20
Evaluate !(1&&1||1&&0)
a) Error
b) True
c) False
Answer: C