497 views

What will be the output of the following code?

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

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

a = ASCII of A = 44
z = ASCII of Z = 69

z-a = 69-44 = 25

### 1 comment

ASCII of A is 65????
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

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

1 vote
1
1,038 views