MCQ Single Best Answer Not Set

QWhat is the output of this C code?
 
#include <stdio.h>
    int main()
    {
        printf("C programming %s", "Class by\n%s atnyla", "WOW");
    }

ID: #1359 Constant in C Language 2,759 views
Question Info
#1359Q ID
Not SetDifficulty
Constant in C LanguageTopic

Choose the Best Option

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

  • A C programming Class by
    WOW atnyla
  • B C programming Class by\n%s atnyla
  • C C programming Class by
    %s Sanfoundry
  • D Compilation error
Correct Answer: Option C

Explanation

Answer:c
This program has only one %s within first double quotes, so it does not read the string "WOW". The %s along with the Sanfoundry is not read as a format modifier while new line character prints the new line. Output:
$ cc pgm2.c
$ a.out
C programming Class by
%s atnyla

Share This Question

Challenge a friend or share with your study group.