Printf MCQ 8 : Multiple Strings seperated by Comma



Printf Multiple Choice Questions : Multiple Strings Separated by Comma

Guess the output of Program -

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Computer","Programming");
getch();
}

[col grid=”2-1 first”]

No Options
1 Computer
2 Programming
3 ComputerProgramming
4 Garbage
[/col]
[col grid=”2-1″]
Output of the Above Program
[/col]


[box style=”light-yellow announcement rounded shadow”]
You can get more printf multiple choice question Here and For More Multiple Choice Question on C Programming - Visit https://www.c4learn.com/mcq/
[/box]

Explanation of Program :

  1. Only First String before comma will be accepted.
  2. If number of Strings are Separated by “Comma” then it will accept only first String because printf looks for double quote immediately after Opening round bracket.
  3. Once corresponding closing double quote is detected, printf will ignore any string written after comma.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Computer : %s","Programming");
getch();
}

In case of above program, Printf finds format string inside printf “%s”. As it is first format specifier printf will look first parameter after comma. So output of the above program will be -

Computer : Programming