GATE 2024 CS (CS2) – Question 36
What is the output of the following C program?
#include <stdio.h>
int main() {
double a[2]={20.0, 25.0}, *p, *q;
p = a;
q = p + 1;
printf("%d,%d", (int)(q - p), (int)(*q - *p));
return 0;}Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (B) 1,5
Explanation
Pointer subtraction gives element count: q − p = 1. Value difference is 25.0 − 20.0 = 5. Output: 1,5.