# C PROGRAMS
C Quiz
➤ Identifiers & Data Types Quiz
➤ Octal Decimal & Hexadecimal
➤ Increment-Decrement Quiz
➤ Relational-Logical Quiz
➤ Arithmetic -Assignment Quiz
➤ Comma Operator Quiz
➤ Sizeof operator Quiz
➤ printf() Quiz Set-1
➤ printf() Quiz Set-2
➤ printf() Quiz Set-3
➤ printf() Quiz Set-4
➤ If statement Quiz in C
➤ If-else statement Quiz
Printf() Quiz in C Set-2 | The printf() function in C is used for output formatting. It is used to display information required by the user and also prints the value of the variables.
It formats the output, like the width of the output, the sign of the output e.t.c. We will learn those formatting using printf() C.
If you finding difficulties to solve these questions then first you should learn these:-
Printf() Quiz in C
Find the output of the programs given in printf Quiz in C Set-2
Q1) Find the output of the given C program.
#include<stdio.h>
int main()
{
printf("%d+%d=%d",1,2,3);
return 0;
}
a) 123
b) 1+2=3
c) 1+2=garbage_value
d) garbage_value + garbage_value = garbage_value
View Answer
Answer:- b) 1+2=3Q2) Find the output of the given C program.
#include<stdio.h>
int main()
{
printf("%d+%d=%d",1,2);
return 0;
}
a) 1+2=garbage_value
b) garbage_value + garbage_value = garbage_value
c) 123
d) 1+2=3
View Answer
Answer:- a) 1+2=garbage_valueQ3) Find the output of the given C program.
#include<stdio.h>
int main()
{
printf("%d+%d=%d",1,2,3,4);
return 0;
}
a) garbage_value + garbage_value = garbage_value
b) 123
c) 1+2=3
d) 1+2=garbage_value
View Answer
Answer:- c) 1+2=3Q4) Find the output of the given C program.
#include<stdio.h>
int main()
{
printf("%d+%d=%d",'1','2','3');
return 0;
}
a) 49+50=51
b) None of these
c) error
d) 1+2=3
View Answer
Answer:- a) 49+50=51Q5) Find the output of the given C program.
#include<stdio.h>
int main()
{
printf("%c+%c=%c",'1','2','3');
return 0;
}
a) 1+2=3
b) None of these
c) 49+50=51
d) error
View Answer
Answer:- a) 1+2=3Q6) Find the output of the given C program.
#include<stdio.h>
int main()
{
printf("%c+%c=%c",65,66,67);
return 0;
}
a) A+B=C
b) error
c) None of these
d) 65+66=67
View Answer
Answer:- a) A+B=CQ7) Find the output of the given C program.
#include<stdio.h>
int main()
{
printf("%c+%c=%c",a,b,c);
return 0;
}
a) 65+66=67
b) A+B=C
c) None of these
d) error
View Answer
Answer:- d) errorThe compiler creates a, b, and c as variables not as constants. The variables must be declared first before using it in the program.
Q8) Find the output of the given C program.
#include<stdio.h>
int main()
{
printf("%d+%d=%d",'a','b','a'+'b');
return 0;
}
a) a + b = a+b
b) a + b = c
c) 97+98=195
d) error
View Answer
Answer:- c) 97+98=195Q9) Find the output of the given C program.
#include<stdio.h>
int main()
{
printf("%d+%d=%D",1,2,3);
return 0;
}
a) None of these
b) error
c) 1+2=%D
d) 1+2=3
View Answer
Answer:- c) 1+2=%DC language is case sensitive, %d, and %D are different. %d is conversion specifier but %D is treated as simple text or string.
Q10) Find the output of the given C program.
#include<stdio.h>
int main()
{
printf("%d%%d=%d",9,2,9%2);
return 0;
}
a) 9%2 = 1
b) 9%d = 2
c) 9%d = 1
d) 9%2 = 2
View Answer
Answer:- b) 9%d = 2In C language, to print ‘%’ we use escape character %% So, in this program %%d converted to string %d. The 9 will be used for the first %d, so before assignment operator, it will display 9%d. Now, after assignment operator %d is there, since 9 is already used and the next constant is 2. Finally, it gives the output 9%2=2, Note that the last constant (9%2) was never used by the program because there was only two %d to display variable but there are three constants (9, 2, 9%2)
If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!
Missing choice a for last question. Also while it’s obvious to someone experienced, for question 7, you should specify “the variables must be declared first if you want the error to go away”. The wording might make newbies think that variables aren’t allowed at all for some reason.
Thank you for the correction. Questions and options are updated now.