Recently while surfing some C++ blogs, I came across a small C teaser program in one of them.
#include<stdio.h>
int find_addr()
{
/*fill your code here*/
}
int main()
{
int i,j;
clrscr();
find_addr();
return 0;
}
The question is to find the address of variables i & j without touching the main function. I haven’t been able to figure it out yet. Feels awful that I couldn’t even solve this minor question :((.
EDIT:
The above program had lot of non-standard statements like the use of inclusion of conio.h anbd other non standard headers and its functions , getch() and other statements, I edited it in a hurry and forgot to omit void from void main(), apologies for that.
EDIT2: I have given my one vote to close this thread since I perceive through the responses posted here that there are non-standard issues related to the question.
I think I found where you read the puzzles. Most of the programs use typeless
main(), or worse,void main(). They assume a lot of system- and/or compiler-specific things. The programs on the page are not very good quality, and make for a bad tutorial. Please stay away from it.For example, this is the first program:
what is the output? Definitely the output is not what you think! so think more..
Third program:
what is the output of the following code if array name starts with 65486?
I could go on, but there is no need really. As I said, stay away from this page!