Is Ch 1-3 Test C++ Your Forte? Find Out With This Quiz!

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Tcarter1
T
Tcarter1
Community Contributor
Quizzes Created: 1 | Total Attempts: 148
Questions: 26 | Attempts: 151

SettingsSettingsSettings
Is Ch 1-3 Test C++ Your Forte? Find Out With This Quiz! - Quiz

C++ language was developed in 1979 and it is a sophisticated general purpose programming language based on C. If you are a starter at this language, then the quiz below is perfect for you, if you consider chapter one to three your forte. Take up the quiz and prove yourself!


Questions and Answers
  • 1. 

    1. Change the following for loop into a while loop
    for( i=0;i < 10; i+=3) {     sum += i; }

  • 2. 

    Explain the difference between a do-while loop and a while loop.

  • 3. 

    Write a complete program that will convert from inches to centimeters. Use the formula     cent = inches * 2.54

  • 4. 

    1. Write a program to add and average test scores for this test. Use a sentinel controlled loop to do this. Do not worry about comments and the intial comment section. This is a complete program.

  • 5. 

    1. Write a switch statement to determine the GPA of a student given the letter grade. Use the following table as a guide.  Double gpa=0,class=0; Letter GPA      A 4.0 B 3.0 C 2.0 D 1.0 F 0.0                

  • 6. 

    1. Write the program again using if-else statements. Determine the GPA of a student given the letter grade. Use the following table as a guide.   Double gpa=0,class=0; Letter GPA      A 4.0 B 3.0 C 2.0 D 1.0 F 0.0                

  • 7. 

        If the following are valid identifiers, check valid, otherwise check invalid, return

    • A.

      Valid

    • B.

      Invalid

    Correct Answer
    B. Invalid
    Explanation
    You cannot use keywords in an identifier.

    Rate this question:

  • 8. 

    STUDENTS

    • A.

      Valid

    • B.

      Invalid

    Correct Answer
    A. Valid
    Explanation
    The given answer "Valid" suggests that the students mentioned in the context are considered valid or acceptable. However, without any additional information or context provided in the question, it is difficult to determine the specific criteria or conditions for determining the validity of the students.

    Rate this question:

  • 9. 

    Student-grade

    • A.

      Valid

    • B.

      Invalid

    Correct Answer
    B. Invalid
    Explanation
    cannot have a dash

    Rate this question:

  • 10. 

    Check_Grade

    • A.

      Valid

    • B.

      Invalid

    Correct Answer
    A. Valid
    Explanation
    The given correct answer is "Valid". This suggests that the "Check_Grade" is a valid action or function. It implies that the system or program is able to check the grade of something or someone, and this action is considered valid or acceptable within the context of the question or problem.

    Rate this question:

  • 11. 

    2file

    • A.

      Valid

    • B.

      Invalid

    Correct Answer
    B. Invalid
    Explanation
    Cannot start with a number

    Rate this question:

  • 12. 

    Cpu

    • A.

      Valid

    • B.

      Invalid

    Correct Answer
    A. Valid
  • 13. 

    Counter value

    • A.

      Valid

    • B.

      Invalid

    Correct Answer
    B. Invalid
    Explanation
    no spaces allowed

    Rate this question:

  • 14. 

    Sprint.L.L.C

    • A.

      Valid

    • B.

      Invalid

    Correct Answer
    B. Invalid
    Explanation
    no periods allowed

    Rate this question:

  • 15. 

    Counter4Data

    • A.

      Valid

    • B.

      Invalid

    Correct Answer
    A. Valid
  • 16. 

    Write only the code necessary to declare a variable that would hold the cost of an automobile.  Initialize it with a value of 0;

    • A.

      Int cost = 0;

    • B.

      Double cost = 0;

    • C.

      Cost = 0;

    • D.

      Double = 0;

    Correct Answer
    B. Double cost = 0;
    Explanation
    The correct answer is "double cost = 0;". This is the correct way to declare a variable named "cost" that can hold decimal values (double) and initialize it with a value of 0.

    Rate this question:

  • 17. 

    Evaluate the following numerical expression. int number; int x = 9, y = 5; float ave = 13.5 number = ( x + y / 3 * 2 ) + ave / x -1 * ave;

    Correct Answer
    -1
    Explanation
    number = (x+y / 3*2) + ave / x - 1 * ave;
    number = (9+5 / 3*2) + 13.5 / 9 - 1 * 13.5;
    number = (9+1*2) + 1.5 - 1 * 13.5;
    number = (9+2) + 1.5 - 13.5;
    number = (11) - 12.0;
    number = - 1.0;
    number = -1;

    Rate this question:

  • 18. 

    Evaluate the following logical expressions as true or false: int x=0, y=1; bool value=false;   (these values are the same for each expression).         (x=0 && y < 5/3 + 3 || value == 0/y)

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    (x=0 && y < 5/3 + 3 || value == 0/y)
    (FALSE && 1 < 5/3 + 3 || false == 0/y)//x=0 is assignment!
    (FALSE && 1 < 1 + 3 || false == 0)
    (FALSE || false == 0)
    (FALSE || TRUE)
    TRUE

    Rate this question:

  • 19. 

    Evaluate the following logical expressions as true or false: int x=0, y=1; bool value=false;   (these values are the same for each expression).     (x + y || value && x || !value)

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    (x + y || value && x || !value)
    (0 + 1 || false && 0 || true)
    (1 || false || true)
    true

    Rate this question:

  • 20. 

    Assume that for each operation, a is 5, b is 14, and c is 8. a, b and c are all integers. a % b

    Correct Answer
    5
    Explanation
    5%14 = 5

    Rate this question:

  • 21. 

    Assume that for each operation, a is 5, b is 14, and c is 8. a, b and c are all integers. a / b

    Correct Answer
    0
    Explanation
    5/14=0

    Rate this question:

  • 22. 

    Assume that for each operation, a is 5, b is 14, and c is 8. a, b and c are all integers. float(a) / c

    Correct Answer
    0.625
    Explanation
    5.0/8 = 5/8 = 0.625

    Rate this question:

  • 23. 

    Assume that for each operation, a is 5, b is 14, and c is 8. a, b and c are all integers. float(a / b)

    Correct Answer
    0.0
    Explanation
    float(0) = 0.0

    Rate this question:

  • 24. 

    1. What is the output of the following code fragment?
    int i=20;   do {     cout << i << i+1 << endl; }while(i > 10);

    • A.

      20 21

    • B.

      10 20 21

    • C.

      20 21 repeating

    Correct Answer
    C. 20 21 repeating
    Explanation
    20 21
    20 21
    20 21
    20 21
    20 21
    20 21
    repeating.

    Rate this question:

  • 25. 

    What is wrong with the following code that will assign my first initial to a variable? char initial; initial=M;

    • A.

      The m needs to have ‘’ around it "M".

    • B.

      The m needs to have ‘’ around it ‘M’.

    • C.

      It is fine.

    Correct Answer
    B. The m needs to have ‘’ around it ‘M’.
    Explanation
    The correct answer is that the m needs to have ‘’ around it ‘M’. In programming, characters need to be enclosed in single quotes ('') to indicate that they are a character literal. Therefore, the correct code should be initial = 'M';

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Feb 17, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Feb 17, 2012
    Quiz Created by
    Tcarter1
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.