#define d 10+10
main()
{
printf("%d",d*d);
}

Answers were Sorted based on User's Feedback



#define d 10+10 main() { printf("%d",d*d); }..

Answer / raj

ans.

d*d will be replaced by 10+10*10+10

during runtime.

so answer is 10+100+10 = 120

Is This Answer Correct ?    88 Yes 0 No

#define d 10+10 main() { printf("%d",d*d); }..

Answer / hussain reddy

120

Is This Answer Correct ?    8 Yes 2 No

#define d 10+10 main() { printf("%d",d*d); }..

Answer / vrushali

This boils down to (10 +10 * 10 + 10)

so answer is 120 ... but if the same macro was rewritten as
#define d (10 + 10)

then d * d = (10 + 10 ) * (10 + 10)
= 20 * 20
= 400....

Pure macro concept....

Is This Answer Correct ?    15 Yes 12 No

#define d 10+10 main() { printf("%d",d*d); }..

Answer / jyothikrishna

Ex:1
#define A 10+10
void main()
{
int a;
a = A*A;
cout<<a<<endl;
}

Ans : 120

Explanation:
When you compile this program. A*A will be converted into 10+10*10+10. Here it follows BODMAS rule first it will perform multiplication and next it will perform addition.

First 10+10*10+10 = 10 + 100 + 10
next 10 + 100 + 10 = 120 (Answer)

Ex:2
#define A (10+10)
void main()
{
int a;
a = A*A;
cout<<a<<endl;
}

Ans : 400

Explanation:
When you compile this program. A*A will be converted into (10+10)*(10+10). Here it follows BODMAS rule first it will perform Bracket values and next it will perform multiplication.

First (10+10)*(10+10) = 20 * 20
next 20 * 20 = 400 (Answer)

Is This Answer Correct ?    2 Yes 1 No

#define d 10+10 main() { printf("%d",d*d); }..

Answer / mangal bhaldare

the value of d is 10+10
so the result is
(10+10)*(10+10)
=120

Is This Answer Correct ?    4 Yes 4 No

#define d 10+10 main() { printf("%d",d*d); }..

Answer / kumaran

400

Is This Answer Correct ?    3 Yes 46 No

Post New Answer

More C Interview Questions

There is a mobile keypad with numbers 0-9 and alphabets on it. take input of 7 keys and then form a word from the alphabets present on those keys.

0 Answers  


When should the volatile modifier be used?

0 Answers  


When should volatile modifier be used?

0 Answers  


Write a program to print factorial of given number without using recursion?

0 Answers  


how to swap four numbers without using fifth variable?

2 Answers  






Why isn't it being handled properly?

0 Answers  


i want to switch my career from quailty assurance engineering to development kindly guide me from which programming language its better for me to start plz refer some courses or certifications too i have an experience of 1.5 yrs in QA field.Kindly guide me

0 Answers   Microsoft,


Explain 'far' and 'near' pointers in c.

0 Answers  


Are bit fields portable?

0 Answers   EXL,


Explain what are global variables and explain how do you declare them?

0 Answers  


What is volatile keyword in c?

0 Answers  


What is #include called?

0 Answers  


Categories