Printf Multiple Choice Questions : Constant Number Instead of Variable in Printf
Predict the Output of the Following Program if Given Things are -
- Two Variables are declared .
- Two Variables are initialized
#include<stdio.h> void main() { int input1 = 10,input2 = 20; printf("%d %d",100); }
- 100 20
- Garbage 20
- 20 10
- Garbage 0
Output :
Switch to Printf MCQ Home : Click Here
How and Why ?
What will Happen If Declaration Line is Replaced by This Line ?
- Undefined Behavior of Printf
- Click Here to See All Observation of Undefined Behavior
- Here First %d <---> 100
- Second %d <---> Latest Initialized Variable
Output :int input1 = 10,input2;
100 10Why ?
- As Explained Above Here First %d <---> 100
- But Second %d Corresponds to Latest Initialized Variable which is input1 = 10
0 Comments:
Post a Comment
Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email