Replies
Welcome, guest
Join CrazyEngineers to reply, ask questions, and participate in conversations.
CrazyEngineers powered by Jatra Community Platform
-
@mangesh6688-2pfEFZ • Jan 6, 2010
The output of this program is 64 which is wrong.
Because the #define square(x) x*x means it will replace the square(x) by x*x
so in program b=64/square(a) will be replaced by b=64/a*a;
As in c++ both / and * has equal priority the expression will be as follows:
b=(64/4)*4; i.e. b=16*4 = 64
So for getting correct output our program should be
#include<iostream.h> #define square(x) (x*x) void main() { int b,a=4; b=64/square(a); cout<<b; } -
@manish-r2Hoep • Jan 6, 2010
yes you are absolutely right
and nice explanation mangesh