C++ Quiz 4

17 Questions | Total Attempts: 473

SettingsSettingsSettings
Please wait...
C Programming Quizzes & Trivia

Questions and Answers
  • 1. 
    What is the output of the following program fragment? cout << static_cast<double>(3)/4 << endl;
    • A. 

      3

    • B. 

      0.5

    • C. 

      0

    • D. 

      0.75

  • 2. 
    When parameters are passed between the calling code and the called function, parameters and arguments are matched by:
    • A. 

      Their data types

    • B. 

      Their relative positions in the parameter and argument lists

    • C. 

      Their names

    • D. 

      They are not matched up at all.

  • 3. 
    If you have the two functions as shown,      int someFunction(int value);      float someFunction(float value); and a variable x, which is a double, which function is called by the following statement?      cout << someFunction(x);
    • A. 

      Void someFunction(int value);

    • B. 

      Void someFunction(float value);

    • C. 

      Nothing, it is a syntax error

    • D. 

      Both functions are called

  • 4. 
    Which of the following are valid function calls to the fabs function?
    • A. 

      Fabs(3.5);

    • B. 

      Cout

    • C. 

      Cin >> fabs(3.5);

    • D. 

      Fabs(cin >> x);

    • E. 

      Fabs(3.5); and cout > fabs(3.5);

    • F. 

      Fabs(3.5); and cout

  • 5. 
    The functions pow(), sqrt(), and fabs() are found in which include file?
    • A. 

      Cstdlib

    • B. 

      Cmath

    • C. 

      Iostream

    • D. 

      Regular

  • 6. 
    The expression static_cast<double>(3) is called a
    • A. 

      Type cast

    • B. 

      Multiplier

    • C. 

      Doubler

    • D. 

      Polymorphism

  • 7. 
    If the variable x has the original value of 3.4, what is the value in x after the following? cout << static_cast<int>(x);
    • A. 

      3.4

    • B. 

      4

    • C. 

      Unknown

    • D. 

      3

  • 8. 
    What is the value of the following? sqrt(sqrt(pow(2,4)));
    • A. 

      1

    • B. 

      2

    • C. 

      4

    • D. 

      16

  • 9. 
    Using functions in a program is known as
    • A. 

      Data abstraction

    • B. 

      Procedural abstraction

    • C. 

      Poor programming style

    • D. 

      Calculus

  • 10. 
    Which of the following are valid function calls to the pow function?
    • A. 

      Pow(int x, int y);

    • B. 

      Pow(2);

    • C. 

      Pow(1.1,3.0);

    • D. 

      Double pow(1.1,3.0);

  • 11. 
    If you have the following variable declaration in your program, const int SIZE=34; then which of the following statements are legal?
    • A. 

      SIZE ++;

    • B. 

      X = SIZE--;

    • C. 

      Cout

    • D. 

      Cin >> SIZE;

  • 12. 
    Which of the following are not legal function declarations?
    • A. 

      Int ave3(int a, int b, int c);

    • B. 

      Int 3ave(int a, int b, int c);

    • C. 

      Int ave3(int, int, int);

    • D. 

      Int ave_3(int a1, int a2, int a3);

  • 13. 
    Information Hiding is analogous to using
    • A. 

      An algorithmic design

    • B. 

      A black-box methodology

    • C. 

      Formal parameters

    • D. 

      Actual parameters

  • 14. 
    Which of the following functions is a properly overloaded function of the following? int doSomething(int first, float second);
    • A. 

      Float doSomething(int first, float second);

    • B. 

      Int doSomething( int next, float last);

    • C. 

      Int doSomething(int first, int second, float third);

    • D. 

      Int doSome(int first, float second);