Escape Sequences In C++ 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 SuryaDevChaturve
S
SuryaDevChaturve
Community Contributor
Quizzes Created: 1 | Total Attempts: 756
Questions: 9 | Attempts: 756

SettingsSettingsSettings
Escape Sequences In C++ Quiz! - Quiz

.


Questions and Answers
  • 1. 

    What is the output - #include<iostream.h> int main() {    cout << "Hello/nProgrammers";  return 0; }

    • A.

      Hello Programmers

    • B.

      Hello/nProgrammers

    • C.

      HelloProgrammers

    • D.

      Error

    Correct Answer
    B. Hello/nProgrammers
    Explanation
    The output of the given code is "Hello/nProgrammers". The code uses the "cout" statement to print the string "Hello/nProgrammers". The "/n" in the string represents a new line character, so when the code is executed, it will print "Hello" on one line and "Programmers" on the next line.

    Rate this question:

  • 2. 

    What is the output - #include<iostream.h> int main() {    cout << "Hello\nProgrammers";  return 0; }

    • A.

      Hello\nProgrammers

    • B.

      Hello Programmers

    • C.

      Hello Programmers

    • D.

      HelloProgrammers

    Correct Answer
    C. Hello Programmers
    Explanation
    The given code will output "Hello Programmers". This is because the code uses the "cout" statement to display the string "Hello Programmers" on the console. The "" symbols in the code are used for input/output stream manipulation in C++, and the "

    Rate this question:

  • 3. 

    What is the output - #include int main() {    cout << "Hello\b\b\bProgrammers";  return 0; }

    • A.

      Hello\b\b\bProgrammers

    • B.

      Hello Programmers

    • C.

      HelloProgrammers

    • D.

      HeProgrammers

    Correct Answer
    D. HeProgrammers
    Explanation
    The output of this code is "HeProgrammers". The "\b" escape sequence is a backspace character, which moves the cursor back one position. In this code, there are three backspace characters ("\b\b\b") immediately after the word "Hello". So when the code is executed, the cursor moves back three positions and overwrites the characters "llo" with "P", resulting in the output "HeProgrammers".

    Rate this question:

  • 4. 

    What is the output - #include int main() {    cout << "\ajay";  return 0; }

    • A.

      \ajay

    • B.

      Ajay

    • C.

      Jay

    • D.

      \a jay

    Correct Answer
    C. Jay
    Explanation
    The code snippet is using the escape sequence "\a" which represents the alert or bell character. When this character is encountered, it produces an audible or visual alert. However, in this case, the output will not produce an audible or visual alert because it is being printed to the console. Therefore, the output will be "jay" printed on separate lines.

    Rate this question:

  • 5. 

    What is the output - #include int main() {    cout << "RAM\rLAL";  return 0; }

    • A.

      LAL

    • B.

      RAM LAL

    • C.

      RAM\rLAL

    • D.

      RALAL

    Correct Answer
    A. LAL
    Explanation
    The output of the given code will be "LAL". This is because the "\r" character is a carriage return character, which moves the cursor back to the beginning of the line. So when the code is executed, it first prints "RAM", then the carriage return moves the cursor back to the beginning of the line, and then "LAL" is printed, overwriting the "RA" from "RAM". Therefore, the final output is "LAL".

    Rate this question:

  • 6. 

    What is the output of the following C++ code? #include int main() {    cout << "Surya\rDiv";  return 0; }

    • A.

      Divya

    • B.

      Surya\rDiv

    • C.

      SurDiv

    • D.

      Surya\rDiv

    Correct Answer
    A. Divya
    Explanation
    The C++ code uses the escape sequence "\r" to move the cursor to the beginning of the line. When "Surya" is printed followed by "\r", it moves the cursor back to the beginning of the line. Then "Div" is printed, overwriting "Surya" with "Div". As a result, the final output is "Divya".

    Rate this question:

  • 7. 

    What is the output - #include int main() {     //  ....... How to print  "Surya"  on console  return 0; }

    • A.

      Cout

    • B.

      Cout

    • C.

      Cout

    • D.

      Cout

    Correct Answer
    C. Cout
  • 8. 

    How to print  "  on console , using cout function?

    • A.

      Cout

    • B.

      Cout

    • C.

      Cout

    • D.

      Cout

    Correct Answer
    C. Cout
    Explanation
    The correct answer is "cout". The question is asking how to print a space on the console using the cout function. The cout function is used in C++ to output data to the console, and by using the statement "cout

    Rate this question:

  • 9. 

    How to print \ajay  on console?

    • A.

      Cout

    • B.

      Cout

    • C.

      Cout

    • D.

      Cout

    Correct Answer
    D. Cout
    Explanation
    The correct answer is "cout" because "cout" is a standard output stream object in C++ that is used to display output on the console. By using the "

    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 17, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Sep 22, 2018
    Quiz Created by
    SuryaDevChaturve
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.