int a = 10 + 10
....
,...
A = A * A

What would be the value of A?
The answer is 120!! Could anyone explain this to me.

Answers were Sorted based on User's Feedback



int a = 10 + 10 .... ,... A = A * A What would be the value of A? The answer is 120!! Could ..

Answer / vinayak bhat

a=10*10
It s a macro concept,,very simple
a=a*a becomes
a=10+10*10+10
* has highest priority than +
hence expression becomes like
a=10+(10*10)+10
a=10+100+10
a=120

Is This Answer Correct ?    24 Yes 6 No

int a = 10 + 10 .... ,... A = A * A What would be the value of A? The answer is 120!! Could ..

Answer / nagarajanselvaraj

In C everything is case sensitive
so variable with name 'a' differs from variable
with name 'A'
The given result is not possible
because 120 is not a square number.

Is This Answer Correct ?    21 Yes 4 No

Post New Answer

More C Code Interview Questions

void main() { int i=5; printf("%d",i++ + ++i); }

3 Answers  


main() { clrscr(); } clrscr();

2 Answers  


how to swap 3 nos without using temporary variable

4 Answers   Satyam,


void func1(int (*a)[10]) { printf("Ok it works"); } void func2(int a[][10]) { printf("Will this work?"); } main() { int a[10][10]; func1(a); func2(a); } a. Ok it works b. Will this work? c. Ok it worksWill this work? d. None of the above

1 Answers   HCL,


main() { float i=1.5; switch(i) { case 1: printf("1"); case 2: printf("2"); default : printf("0"); } }

2 Answers  






main() { char string[]="Hello World"; display(string); } void display(char *string) { printf("%s",string); }

2 Answers   Wipro,


Write a C program to print look and say sequence? For example if u get the input as 1 then the sequence is 11 21 1211 111221 312211 12112221 .......(it counts the no. of 1s,2s etc which is in successive order) and this sequence is used in run-length encoding.

1 Answers  


main() { char *cptr,c; void *vptr,v; c=10; v=0; cptr=&c; vptr=&v; printf("%c%v",c,v); }

1 Answers  


Write a program using one dimensional array to assign values and then display it on the screen. Use the formula a[i]=i*10 to assign value to an element.

1 Answers   Samar State University,


main() { register int a=2; printf("Address of a = %d",&a); printf("Value of a = %d",a); }

3 Answers  


main() { char *p = “ayqm”; printf(“%c”,++*(p++)); }

29 Answers   IBM, TCS, UGC NET, Wipro,


Print an integer using only putchar. Try doing it without using extra storage.

2 Answers  


Categories