I'm sharing one interview question asked to me at Hewlett-Packard.
Program :
#include<stdio.h>
#include<conio.h>
int main ()
{
int a=3;
printf("The value of a is : %d",a);
printf("\nAddress of a is : %u",&a);
getch ();
return 10;
}
Question :
Run this program, you'll get the address of a as 65524, however the maximum decimal value_16 bit is 65535 (unsigned). Why the address at the output is 65524 not 65535 ?
Question :
Prove using DOS that the return value of the above program is 10 ?
Hint : (echo %errorlevel%)
Program :
#include<stdio.h>
#include<conio.h>
int main ()
{
int a=3;
printf("The value of a is : %d",a);
printf("\nAddress of a is : %u",&a);
getch ();
return 10;
}
Question :
Run this program, you'll get the address of a as 65524, however the maximum decimal value_16 bit is 65535 (unsigned). Why the address at the output is 65524 not 65535 ?
Question :
Prove using DOS that the return value of the above program is 10 ?
Hint : (echo %errorlevel%)