5 votes 5 votes What will be the maximum value printed by the following C program? #include<stdio.h> int main() { int i = 0; char* p = "THISISRIDICULOUS"; while(*(p+i) != '\0') { printf("%d ", *(p+i++) - 'A'); } } Programming in C go2025-programming-1 numerical-answers pointers + – gatecse asked Jul 26, 2020 • edited Jul 26, 2020 by Lakshman Bhaiya gatecse 318 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 3 votes 3 votes The highest value alphabet here is 'U' and the difference of 'U' and 'A' is $20.$ gatecse answered Jul 26, 2020 • selected Jul 24, 2021 by Arjun gatecse comment Share Follow See all 2 Comments See all 2 2 Comments reply sidhartha yadav commented Jan 3, 2022 reply Follow Share sir can you pls eloborate..?? 0 votes 0 votes sk91 commented Jan 29, 2022 reply Follow Share The while loop iterates over all the characters of the string pointed by p till end of string is reached. In the print statement, *(p+i++) evaluates to ‘T’ in the 1st iteration ( due to post increment ) i=0 – *(p+i++) - 'A’ => ‘T’ – ‘A’ = 84 -65 = 19 ( consider ASCII values ) i=1 – *(p+i++) – ‘A’ => ‘H’ – ‘A’ = 72 – 65 = 7 and so on. Now, max value will be printed for ‘U’ which is 85-65 = 20 1 votes 1 votes Please log in or register to add a comment.