Sunday 14 April 2013

Pointer Variables Program


What will be output of following program?

#include<stdio.h>
#include<string.h>
int main(){
int a = 5,b = 10,c;
int *p = &a,*q = &b;
c = p - q;
printf("%d" , c);
return 0;
}
(A) 1

(B) 5

(C) -5

(D) Compilation error

(E) None of above


________________________________________
Explanation:

Turbo C++ 3.0: 1

Turbo C ++4.5: 1

Linux GCC: 1

Visual C++: 2



Difference of two same type of pointer is always one.

No comments:

Post a Comment