N
nash_r
hi,
i have 3 probs dats getting me all confused.
i m using Turbo C compiler.
1. #define PRODUCT(x) (x*x)
main()
{
int i=3,j;
j=PRODUCT(i+1);
printf("\n%d",j);
}
the prob is the output.I can't understand the logic behind it's
output.
2. #define PRODUCT(x) (x*x)
main()
{
int i=3,j,k;
j=PRODUCT(i++);
k=PRODUCT(++i);
printf("\n%d%d",j,k);
}
the prob in this case is also the output.
in the 'j' case the output come to be 9 and in the 'k' case it comes
to 49.
the quest. is y is the compiler adding it all up after the macro in
case of 'j' and twice b4 the operation in case of 'k' giving an output
of 49.
3. in the same prob as mentioned above if we replace the i++ by i++ in
case of 'j' it shows an error statin "Lvalue required" at compile
time.And if we use the following code
#define PRODUCT(x) (x*x)
main()
{
int i=3,j;
j=PRODUCT(++++i);
printf("\n%d",j);
}
the output observed is 35.
how is the operation proceeding and y is it saying Lvalue required in
case we use i++++ and y 35 (which seems arising from 5 and 7)coming
when according to conventional wisdom it shld be 49 (refering from
prob 2 stated above).
thnks
i have 3 probs dats getting me all confused.
i m using Turbo C compiler.
1. #define PRODUCT(x) (x*x)
main()
{
int i=3,j;
j=PRODUCT(i+1);
printf("\n%d",j);
}
the prob is the output.I can't understand the logic behind it's
output.
2. #define PRODUCT(x) (x*x)
main()
{
int i=3,j,k;
j=PRODUCT(i++);
k=PRODUCT(++i);
printf("\n%d%d",j,k);
}
the prob in this case is also the output.
in the 'j' case the output come to be 9 and in the 'k' case it comes
to 49.
the quest. is y is the compiler adding it all up after the macro in
case of 'j' and twice b4 the operation in case of 'k' giving an output
of 49.
3. in the same prob as mentioned above if we replace the i++ by i++ in
case of 'j' it shows an error statin "Lvalue required" at compile
time.And if we use the following code
#define PRODUCT(x) (x*x)
main()
{
int i=3,j;
j=PRODUCT(++++i);
printf("\n%d",j);
}
the output observed is 35.
how is the operation proceeding and y is it saying Lvalue required in
case we use i++++ and y 35 (which seems arising from 5 and 7)coming
when according to conventional wisdom it shld be 49 (refering from
prob 2 stated above).
thnks