What number would be shown on the screen after the following statements of C are executed?
char ch;
int i;
ch = 'G';
i = ch-'A';
printf("%d", i);
char ch;
int i;
ch = 'G';
i = ch-'A';
printf("%d", i);
A. 5
B. 6
C. 7
D. 8
E. 9
Answer: Option B
Solution(By Examveda Team)
Since the ASCII value of G is 71 and the garbage value if A is 65 and hence the difference is 6.
Join The Discussion
Comments ( 4 )
Related Questions on C Fundamentals
What is the primary purpose of a function prototype in C?
A. Declare a variable
B. Declare a function
C. Define a function
D. Assign a value
What is the correct syntax for declaring a variable in C?
A. int variable_name;
B. variable_name = 5;
C. variable_name int;
D. int = variable_name;
2nd solution
In hexadecimal value of A is 10 & G is 16
So answer will be 6
option B
option B
option B