in Programming in C
792 views
3 votes
3 votes

What will be the output of the following code?

#include <stdio.h>
int main()
{
    char a = 'A', z = 'Z';
    printf("%d", z-a);
}
in Programming in C
by
792 views

4 Answers

6 votes
6 votes
Best answer

Here we don't even need to remember the ASCII codes

For A: ASCII of A = x

For B: ASCII of B = x+1

:

For Z: ASCII of Z = x+25

Hence z-a = x+25 - x = 25 

selected by
2 votes
2 votes
a = ASCII of A = 44
z = ASCII of Z = 69

z-a = 69-44 = 25
edited by

1 comment

ASCII of A is 65????
0
0
0 votes
0 votes
Here value is print by ascii code  conversion . let suppose a=1 and z=26 because total number of character present is 26 a is 1st and z is 26th character of alphabhat

so z-a= 26-1=25

so 25 will be printed
0 votes
0 votes

ASCII value of z - ASCII value of a = 25.

See: https://gateoverflow.in/55882/ugcnet-june2012-ii-38

Answer:

Related questions