ch*******@yahoo.com wrote:
main()
int main (void)
{
int i;
clrscr();
Not a standard function.
printf("%d", &i)+1;
printf is expecting an int, you are passing a pointer to int, this is
undefined behavior. Try printf("%d\n", i);
You need to #include <stdio.h> before calling printf.
You need to initialize i before using it's value, what you are doing is
undefined behavior.
scanf("%d", i)-1;
scanf is expecting a pointer to int, you are passing an int. Try
scanf("%d", &i);
You need to #include <stdio.h> before calling scanf.
}
whats the output n why???
You have several examples of undefined behavior in your program, this
means anything goes, you shouldn't expect anything in particular.
Note that there is & which means it probably prints the address of
i...n my guess is that + 1 has no effect on the output...
If you want to print the address, cast the address of i to a pointer to
void and use the %p conversion specifier:
printf("%p\n", (void *)&i);
printf returns an integer value. In your statement 1 is added to the
this value and the result is discarded. The compiler could legally
just remove the +1 as an optimization since your program wouldn't know
the difference, it doesn't use the result in any way.
Robert Gamble