What is the output of the followint -c- code#define square(a) (a*a)main(){printf("%d",square(4+5));}

Questions by pvrajesh

Showing Answers 1 - 24 of 24 Answers

shrine margaret

  • Oct 24th, 2005
 

Question: what is the output of the followint -c- code
#define square(a) (a*a)
main()
{
printf("%d",square(4+5));
}

Answer: 81



 

Deepak Singh

  • Oct 24th, 2005
 

Preprocessor will replace square(4+5) by 4+5*4+5 in printf statementEvaluating 4+5*4+5 will give 29 since "*" has more precedence than "+".

mohan

  • Dec 26th, 2005
 

the corrct preprocesser declaration is #define square(a) ((a)*(a))then th answer is 81otherwise its take (4+5*4+5) answser wass 29

ashish khandelwal

  • Feb 6th, 2006
 

ans-29

4+5*4+5=4+20+5=29

viswanadham

  • Feb 10th, 2006
 

instead of interpreting 9*9 it will be interpreted as 4+5*4+5

first it will calculate 5*4=20 then 4+20+5=29

so instead of giving 9*9=81 it will give 29.

bai...

from vissu......

manikandan

  • Aug 5th, 2006
 

The answer of the coding is:81

      #define squre(a) (a*a);

The value of squre(4+5) is 81,Because the compiler consider 4+5 is 9,so a=9

But already defined a is a*a ,so answer is 91.

  Was this answer useful?  Yes

raja

  • Aug 25th, 2006
 

 this program out put is 81

Nagarajukumar

  • Oct 10th, 2006
 

Hi

This is nagaraju .The output is 29

timmy

  • Mar 4th, 2007
 

The behavior of the printf is undefined because there is not
prototype in scope.

  Was this answer useful?  Yes

Ritu

  • Apr 4th, 2007
 

The output is indeed 29
You can run the program and see...

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions