Printf Multiple Choice Questions 23 : Character array Assigned to Character Variable
Predict the Output of the Following Program if Given Things are -
#include<stdio.h> void main() { char ch = 'ABCDEF'; printf("%c",ch); }
Options :
- A
- ABCDEF
- Compile Error
- Run Time Error
Switch to Printf MCQ Home : Click Here
How and Why ?
- Confused !!! Why You get Compile Time Error ?
- Reason being that , Character Variable can Store Single Character
- ch is character Type and ‘ABCDEF’ is String and Shown in Single Quotes which violets the Definition of Character and Array of Character