Sie sind auf Seite 1von 8

Page One Answers

Question #1 Question #6 What number of digits that can be accurately stored Evaluate the following as true or false: ! in a float (based on the IEEE Standard 754)? (1 &&0 || !1) 6 38 An unlimited number Question #2 Which of the following is evaluated first: && || ! Question #3 What does 7/9*9 equal (in C and C++)? 1 0.08642 0 Question #4 Question #9 Which is not valid in C? class aClass{public:int x;}; /* A comment */ char x=12; Question #5 Question #10 Which of the following is not a valid declaration for main()? int main() int main(int argc, char *argv[]) They both work True or false: If you continuously increment a variable, it will become negative? True False It depends on the variable type Which is not an ANSI C++ function? sin() kbhit() tmpnam() True False Invalid statement Question #7 Which command properly allocates memory? char *a=new char[20]; char a=new char[20]; char a=new char(20.0); Question #8 What operator is used to access a struct through a pointer? -> >> *

Page Two Answers

Question #11 Question #16 What character terminates all strings composed Which of the following data structures is on of character arrays? average the fastest for retrieving data: \0 . \END Question #12 If you push 1, 3, and 5 - in that order - onto a stack, which number is popped out first? Binary Tree Hash Table Stack Question #17

What is the output of the following code: int v() { int m=0; 5 return m++; 1 } 3 int main() { Question #13 cout<<v(); What does the code strcat(an_array, "This"); } do? 1 0 Copies "This" into an_array Code cannot compile Adds "This" to the end of an_array Compares an_array and "This" Question #14 Evaluate the following: 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); 10 11 1 Question #15 Evaulate the following: 22%5 2 4 0 Question #18 Which of the following functions initalizes the variables contained in a class: Constructor Destructor Constitutor Question #19 Is C++ case sensitive? No Case sensitivity is compiler-determined Yes Question #20

Which datatype can store decimal numbers?

unsigned int char float

Question #21 What does the code "cout<<(0==0);" print?

0 1 Compiler error: Lvalue required Question #22 According to the ANSI C++ standard, what does the getch() do? Reads in a character Checks the keyboard buffer Nothing (getch() is not an ANSI C++ function) Question #23 If the program completes executing successfully, what value should the function main() return? 0 1 void Question #24 C is to C++ as 1 is to What the heck? 2 10 Question #25 Which of the following sorts is quickest when sorting the following set: 1 2 3 5 4 Quick Sort Bubble Sort Merge Sort Question #26 What does the following code do: int foo (int x, int y) { cout << x << y ; } int c=0; foo( c++, c ); Undefined 01 00 Question #27 What is the maximum value of an unsigned char? 255 256 128 Question #28 In the following declaration of main, "int main(int argc, char *argv[])", to what does argv[0] usually correspond? The first argument passed into the program The program name You can't define main like that

Question #29 In which header file is isalpha() declared? conio.h stdio.h ctype.h Question #30 What will happen when the following code is run: int x; while(x<100) { cout<<x; x++; } The computer will output "0123...99" The computer will output "0123...100" The output is undefined

Page Four Answers

Question #31 Will a C compiler always compile C++ code? Yes. No. Only optimized compilers will compile C++ code. Question #32 Which of the following is not a valid keyword: public protected guarded Question #33 What is the correct syntax for inheritance? class aclass : public superclass class aclass inherit superclass class aclass <-superclass Question #34 What does the following code snippet do: for(;;) ; The snippet is illegal It loops forever It is ignored by compiler, but it is not illegal Question #35 Of the numbers 12, 23, 9, and 28, which one would be at the top of a properly implemented maxheap? 28 9 Any of them could be Question #36 What does the line containing "break;" do in the following code? void afunction() { if(1) { break; a_function(); cout<<"Err"; } } Breaks out of the if statement Exits the function Nothing (Compiler error) Question #37 To what value are pointers initialized? NULL Newly allocated memory No action is taken by the compiler to initialize pointers. Question #38 What is the last index number in an array of 100 chars? 100 99 101 Question #39 Would you rather wait for the results of a quicksort, a linear search, or a bubble sort on a 200000 element array? Quicksort Linear Search Bubble Sort Question #40

Which of the following data structures uses the

least memory? struct astruct { int x; float y; int v; }; union aunion

{ };

int x; float v;

char array[10];

Page 5 Answers
Question #41 Question #46 What does the following code do? void Evaluate !(1&&1||1&&0) afunction(int *x) { Error x=new int; True *x=12; False } int main() Question #47 { int v=10; What header file is needed for the function exit()? afunction(&v); cout<<v; stdlib.h } conio.h dos.h Outputs 12 Outputs 10 Question #48 Outputs the address of v Question #42 What ANSI C++ function clears the screen?

To what value do nonglobal variables clrscr() clear() default? There is no function, defined by the ANSII C++ standard, which will clear the screen auto register Question #49 static Question #43 When run on a computer, will a recursive function without an end condition ever quit?

Which header file allows file I/O with Compiler-Specific (Some compilers can convert these streams? functions to infinite loops) No iostream Yes fstream fileio.h Question #50 Question #44

How long does the following code run? for(int x=0;

What is the outcome of the line of code x=3; x++) "cout<<abs(-16.5);"? Never Three times 16 Forever 17 16.5 Question #45 What value will "strcmp("Astring", "Astring");" return? A positive value A negative value Zero