6th c++ Problem
have a look of this code
#include#define square(x)x*x void main() { int b,a=4; b=64/square(a); cout<Tell me the output...?and if it gives wrong output then give me correct output?
ie i want b=4
Replies
-
Mangesh6688The 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
#define square(x) (x*x) void main() { int b,a=4; b=64/square(a); cout< -
Manish Goyalyes you are absolutely right
and nice explanation mangesh
You are reading an archived discussion.
Related Posts
I Believe we have lot of CEans who have given thier CCNA exams. One thing which I am unable to find - is a proper lab set up .
I...
Googsystray
Version: 1.0.3
File Size: 8747
License: Free
Googsystray is a system tray application designed for Google Voice, GMail, Google Calendar, and Google Reader. This application will notify you on...
A man checked into a hotel. There was a computer in his room,
so he decided to send an e-mail to his wife. However, he accidentally
typed wrong e-mail address,...
Hi
I know vbulletin has this option where you can add prefix to the thread. I think this will be particularly useful in forums that are shared by two different...
Hi there,
Civil engineer here. I have a diploma in civil engineering but now working towards getting a degree. My main reason for joining this forum is to keep my...