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
ASCII value of z - ASCII value of a = 25.
See: https://gateoverflow.in/55882/ugcnet-june2012-ii-38
64.3k questions
77.9k answers
244k comments
80.0k users