Multiple choice

How can the integer variable n be displayed in octal format in C++?

  1. cout<<oct(n);

  2. cout<<octal(n);

  3. cout<<n<<oct;

  4. cout<<oct<<n;

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

To display the integer variable in octal format, we have to use the “oct” keyword between the cout and variable using << operator.