Presentation is loading. Please wait.

Presentation is loading. Please wait.

1. 2 Review How many bits are in a byte? a) 4 b) 8 c) 16 d) 256.

Similar presentations


Presentation on theme: "1. 2 Review How many bits are in a byte? a) 4 b) 8 c) 16 d) 256."— Presentation transcript:

1 1

2 2 Review How many bits are in a byte? a) 4 b) 8 c) 16 d) 256

3 3 iostream is part of: a) the comment section b) the C++ standard library c) the compiler d) the main function

4 4 Which of the following lines must end with a semicolon (;)? a) #include b) int main ( ) c) // a comment d) using namespace std

5 5 Which of the following is a compiler directive: a) #include b) using namespace std; c) int main ( ) d) return 0;

6 6 Which of the following is not a valid identifier? a) Pig3 b) I_HAVE_A_DOG c) help! d) _answer

7 7 What would be the best choice of data type for a person’s address? a) int b) float c) char d) string

8 8 Which of the following statements is correct? a) float num1; num2; b) int day, night; c) int blue = 5.0; d) string black = ‘white’;

9 9 Which of the following is a valid function prototype? a) float some function ( ); b) void nothing; c) int (int thing); d) void something ( );

10 10 Which of the following function calls is valid for the function prototype? int calculation (int m, char p, float q); a) cout << calculation (3, “yes”, 2.0); b) cout << calculation (5, p, 4.5); c) cout << calculation (5, ‘s’); d) cout << calculation (10, ‘r’, 7.0);

11 11 Which of the following is not a logical operator? a. || b. = c. ! d. &&

12 12 Which of the following is equivalent to (p >= q) a. p < q b. !(p < q) c. p > q d. !p < q

13 13 What is the output of the following function call given the function definition below? cout << myFunction (8); // function call int myFunction (int x)//function definition { bool flag = false; while (!flag) { x = x + 1; flag = ((x % 2 == 0) && (x % 3 == 0)); } return x; }

14 14 What is the output of this code, given the following function definition? int x =5, y = 2; y = mixUp (x, y); cout << x; int mixUp (int &p, int t)//function definition { p = p * t; return p + 1; }

15 15 When should a parameter be a reference parameter? a)When the parameter is carrying information into the function that does not have to be returned b)When the parameter is carrying information into the function that may be changed and the new value should be returned c)When the information is to be returned from the function using the parameter. d)Both b and c

16 16 int a = 4, b = 10; a = aFunction (a, b); cout << a << “ “ << b; int aFunction (int j, int &k) // function definition { while (j < k) { j++; k -= 2; } return j; }

17 17 Given the function prototype and variable declarations, which of the following is a valid function call? void tryOut ( int, char, int&, float&);// function prototype int a = 4, b = 0;//variable declarations float y; char c; a) tryOut (3, ‘a’, 5, y); b) tryOut (a, c, a * b, y); c) tryOut (8, ‘t’, b, 7.8); d) tryOut (a + b, ‘b’, b, y);

18 18 Given the function prototype and variable declarations, which of the following is a valid function call? void compute (int, float, char&, int& ); // function prototype int x, y; //variable declarations float p, q; char r, s; a) compute (x, 7.3, ‘c’, y); b) compute (y, p, s, x + y); c) compute (5, p + q, r, y); d) compute (x, s, r, 8);

19 19 What is the value of the following expression? char (int (‘z’) – int (‘w’) + int (‘A’)) a) 3 b) 67 c) E d) D

20 20 Which of the following is the complement of (x && y)? 1.!x && !y 2.! (x && y) 3.!x || !y a) 2 only b) 1 and 2 c) 3 only d) 2 and 3

21 21 What is the code that associates the input file stream inf with the file myFile.txt? a) … ifstream myFile.txt; inf.open (myFile.txt); b) #define aFile myFile.txt … ifstream aFile; inf.open (aFile); c) #define aFile “myFile.txt” … ifstream inf; inf.open (aFile); d) #define aFile “myFile.txt” … ifstream inf; inf.open (myFile.txt);

22 22 Using the definition below, which of the following declares a variable of struct type book with title “War & Peace” and price 27.99. struct book { string title; float price; }; a) book myBook; title = “War & Peace”; price = 27.99; b) book myBook; myBook.title = “War & Peace”, price = 27.99; c) book myBook; myBook[title] = “War & Peace”; myBook[price] = 27.99; d) book myBook; myBook.title = “War & Peace”; myBook.price = 27.99;

23 23 What is the output of the following code? int list[5] = {4, 7, 5, 3, 0}; int x = 3; list[x] = list[2 * x – 4]; list[x+1] += 6; list[x-1] = list[x-2]; cout << list[1] << list[2] << list[3] << list[4];


Download ppt "1. 2 Review How many bits are in a byte? a) 4 b) 8 c) 16 d) 256."

Similar presentations


Ads by Google