Bhs Junior Quiz - C++ Conditional Statement -if

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 Missyoung
M
Missyoung
Community Contributor
Quizzes Created: 2 | Total Attempts: 3,083
Questions: 5 | Attempts: 1,278

SettingsSettingsSettings
Programming Language Quizzes & Trivia

Welcome Juniors to using Proprofs on-line assessment. This is the first of many on-line assessments that will be done this semester. This is a timed quiz so work efficiently.


Questions and Answers
  • 1. 

    Write a program that prompts the user to enter the age of a customer.  If the age is younger than 15, then ask the user to enter the name of the customer and notify them by name that they qualify for a free toy.

  • 2. 

    The programming language of C++ was written by Bjarne Stroustrup.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Bjarne Stroustrup is the creator of the C++ programming language. He developed C++ as an extension of the C programming language, adding object-oriented programming features. Therefore, the statement that the programming language of C++ was written by Bjarne Stroustrup is true.

    Rate this question:

  • 3. 

    In a conditional statement to determine if the sum of x and y is equal to z, then a = x+y, what is the actual condition in C++?

    • A.

      If(sum=z) { a=x+y; }

    • B.

      Sum = z

    • C.

      If (x+y=z)

    • D.

      X+y=z

    Correct Answer
    D. X+y=z
    Explanation
    The actual condition in C++ is "x+y=z". This condition checks if the sum of x and y is equal to z. If it is true, then the code block inside the if statement will be executed, which assigns the value of x+y to the variable a.

    Rate this question:

  • 4. 

    To determine whether or not a person is an adult based on their current age, the most appropriate conditional statement to use is the _______________________ statement.

    Correct Answer
    if
    if-else
    if-else
    loop
    Explanation
    The most appropriate conditional statement to use when determining whether or not a person is an adult based on their current age is the "if" statement. This statement allows for a single condition to be checked and a corresponding action to be taken if the condition is true. However, if additional conditions need to be checked and different actions need to be taken based on those conditions, the "if-else" statement or the "if-else if-else" statement can be used. A loop statement, on the other hand, is used for repeating a block of code multiple times.

    Rate this question:

  • 5. 

    Select the correct code for the following statement: If the name of a person is definitely Joe, say hello.

    • A.

      If(nam=Joe) {cout

    • B.

      If(nam!='Joe') {cout

    • C.

      If(nam=="Joe") {cout

    • D.

      If(nam=="Joe") {cout>>"hello"}

    Correct Answer
    C. If(nam=="Joe") {cout
    Explanation
    The correct code for the given statement is "if(nam=="Joe") {cout". This code checks if the value of the variable "nam" is equal to the string "Joe". If it is, then it will execute the code inside the curly braces, which in this case is printing "hello".

    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
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Jan 09, 2018
    Quiz Created by
    Missyoung
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.