Sunday 14 April 2013

Register variable program


What will be output of following program?

#include<stdio.h>
#include<string.h>
int main(){
register a = 25;
int far *p;
p=&a;
printf("%d ",*p);
return 0;
}
(A) 25

(B) 4

(C) Address

(D) Compilation error

(E) None of above


________________________________________
Explanation:

Turbo C++ 3.0: Compilation error

Turbo C ++4.5: Compilation error

Linux GCC: Compilation error

Visual C++: Compilation error



Register data type stores in CPU. So it has not any memory address. Hence we cannot write &a.

No comments:

Post a Comment