C Programming :: Basic Concepts - Discussion
Home > C Programming > Basic Concepts > MCQs Questions Discussion
22 / 90
What is the output of the following 'C' program ?
#include<stdio.h>
void main()
{
char ch = 'A';
printf ("%d%d",sizeof(ch),sizeof('A'));
}
#include<stdio.h>
void main()
{
char ch = 'A';
printf ("%d%d",sizeof(ch),sizeof('A'));
}
A1 1
B2 2
C1 4
D2 1
Answer: Option (Login/Signup)
Show Explanation
The size of char is 1 byte, hence sizeof(ch) is equal to 1.
Whereas, 'A' is a character constant, which is seen as an int. We know the size of int is 4 bytes hence, sizeof('A') is equal to 4.
Therefore, the output is 1 4.
Asked In ::
STEP-BY-STEP
Here, 'ch' is a character type variable.
The size of char is 1 byte, hence sizeof(ch) is equal to 1.
Whereas, 'A' is a character constant, which is seen as an int. We know the size of int is 4 bytes hence, sizeof('A') is equal to 4.
Therefore, the output is 1 4.
Read Full Answer
Report Error
Please Login First Click Here