Docsity

C++ Programming Quiz: Identifying Variables, Constants, and Objects - Prof. Ju Wang, Study notes of Computer Science

Toggle sidebar
bg1
1. What is the first step in the Software Development Process?
[A] Code
[B] Test
[C] Requirements
[D] Design
2. Which of the following are valid C++ identifiers?
[A] age
[B] _grade
[C] return
[D] b234
[E] 3Numbers
[F] 123
3. A variable’s scope
[A] determines where it can be used in a program.
[B] can be changed during run time
[c] should be assigned to zero at the end of the program
[D] must be declared before the main function.
4. Constants
[A] are variables whose values can’t be changed.
[B] are identities with a fixed value
[C] must be defined before the main progtam
[D] can’t be used in function
5. Which of the following objects and functions are used for Standard
Input and Output in C++?
[A] print
[B] cin
[C] cout
[D]getline
5. Using the following code snippet what is the value of "grade"?
int A=11, B=9, grade;
grade = A-- * B++;
[A] 20
[B] 99
[C] 32
[D] 100
[E] 0
6. What is the value of animal after the if statement is executed?
bool cat=true, dog=false;
bool animal;
pf3
pf4

Partial preview of the text

Download C++ Programming Quiz: Identifying Variables, Constants, and Objects - Prof. Ju Wang and more Study notes Computer Science in PDF only on Docsity!

  1. What is the first step in the Software Development Process? [A] Code [B] Test [C] Requirements [D] Design
  2. Which of the following are valid C++ identifiers? [A] age [B] _grade [C] return [D] b [E] 3Numbers [F] 123
  3. A variable’s scope [A] determines where it can be used in a program. [B] can be changed during run time [c] should be assigned to zero at the end of the program [D] must be declared before the main function.
  4. Constants [A] are variables whose values can’t be changed. [B] are identities with a fixed value [C] must be defined before the main progtam [D] can’t be used in function
  5. Which of the following objects and functions are used for Standard Input and Output in C++? [A] print [B] cin [C] cout [D]getline
  6. Using the following code snippet what is the value of "grade"? int A=11, B=9, grade; grade = A-- * B++; [A] 20 [B] 99 [C] 32 [D] 10 0 [E] 0
  7. What is the value of animal after the if statement is executed? bool cat=true, dog=false; bool animal;

if (cat && dog) { animal = true; } else animal = false; [A] true [B] false [C] dogcat [D] catdog

  1. A statement in a C++ program must end with [A] a semicolon? [B] a period [C] a coma [D] a verb
  2. What is the value of X after the loop has terminated? int X = 0; for (int n=10; n>0; n) { X = n; } [A] 10 [B] 19 [C] 1 [D] 0
  3. A function [A] is a group of statements. [B] must not be empty [C] should at least contain one variable [D] must be called from some point in the main function of the program.
  4. The following function returns what value? void addNumber (int a, int b) { int c; c = a + b; return; } [A] Value of c [B] Value of a [C] Nothing [D] Depends on the values passed in
  5. An array [A] is many of elements of the different type placed in contiguous memory locations [B] element can be individually referenced by using an index with the array name
  1. 7 + 6 % 5 ; ans:___________ [A] 8 [B] 3 [C] 7. [D] 6
  2. Let m and n be two integer variables defined already, which of the following statement are legal: [A] m+n; [B] m+3; [C] 3=n+m; [D] n+m=4; [E] n=m+3; [F] 3=m; [G] 3==m;
  3. We have the following class and object definition: class x{ int y; int z; }; x w; Which of the following are correct: [A] w.y=1; [B] x.y=1; [C]y.z=1; [D] x.w=1; [E] w.x=1; [F] w.z=1;