Printf MCQ 24 : Character array of Length = 2 Assigned to Character Variable
Printf Multiple Choice Questions 24 : Character array of Length = 2 Assigned to Character Variable
Predict the Output of the Following Program if Given Things are -
#include<stdio.h> void main() { char ch = 'AB'; printf("%c",ch); }
Options :
- A
- AB
- Compile Error
- Run Time Error
[toggle title=”Output”]A[/toggle]
Switch to Printf MCQ Home : Click Here
How and Why ?
- Output is ‘A’ is Printed
- Reason being that , Character Variable can atmost array of Two Characters
- Example ‘n’ Though it has two Characters but it is Interpreted as Single Character , Similarly ‘AB’ is theoratically considered as Single Variable
Rule :
- Character Variable can Store atmost Two Characters