Single Choice Not Set

QWhat will be the output of the following program?
 
#include<stdio.h>
void main()
{
printf("Rambo \n");
printf("\"Rambo\" \n");
printf("\\Rambo\\ \n");
printf("50%% \n"); 
}

ID: #1263 Constant in C Language 1,989 views
Question Info
#1263Q ID
Not SetDifficulty
Constant in C LanguageTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A
     Rambo
    "Rambo"
    \Rambo\
    50%
  • B
     Rambo
    "Rambo"
    \\Rambo\\
    50%%
  • C
     Rambo
    "Rambo"
    \\Rambo\
    50\%
  • D Error
Correct Answer

Explanation

Without a backslash, special characters have a natural special meaning. With a backslash they print as they appear.
\   -   escape the next character
"   -   start or end of string
’   -   start or end a character constant
%   -   start a format specification
\\  -   print a backslash
\"  -   print a double quote
\’  -   print a single quote
%%  -   print a percent sign
The statement printf(" \" "); will print you the quotes. You can also print these special characters \a, \b, \f, \n, \r, \t and \v with a (slash) preceeding it.

Share This Question

Challenge a friend or share with your study group.