What is the output of the following code? #include<stdio.h>void main(){char letter =Z;printf("\n%c",letter);}
Reveal answer
Fill a bubble to check yourself
What is the output of the following code? #include<stdio.h>void main(){char letter =Z;printf("\n%c",letter);}
Z
90
Error
Garbage Value
To answer this question, let's go through each option to understand why it is correct or incorrect:
Option A) Z - This option is correct because the code initializes a variable letter with the value Z, and then uses the printf function to print the value of letter using the %c format specifier. The %c format specifier is used to print a single character, so the output will be the character Z.
Option B) 90 - This option is incorrect. The ASCII value of the character Z is 90, but the code is not printing the ASCII value. It is printing the character itself.
Option C) Error - This option is incorrect. There is no error in the code.
Option D) Garbage Value - This option is incorrect. The code explicitly initializes the variable letter with the value Z, so there is no garbage value involved.
The correct answer is A) Z. This option is correct because the code prints the character Z.