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

What are segment and offset addresses?

2 Answers   Infosys,


void main() { char a[]="12345\0"; int i=strlen(a); printf("here in 3 %d\n",++i); }

3 Answers  


Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all.

2 Answers   Mentor Graphics, Microsoft,


Is this code legal? int *ptr; ptr = (int *) 0x400;

1 Answers  


main(){ char a[100]; a[0]='a';a[1]]='b';a[2]='c';a[4]='d'; abc(a); } abc(char a[]){ a++; printf("%c",*a); a++; printf("%c",*a); }

2 Answers  






Program to find the largest sum of contiguous integers in the array. O(n)

11 Answers  


Write a program to check whether the number is prime and also check if it there i n fibonacci series, then return true otherwise return false

1 Answers   Cognizant, lenovo,


main() { int i = 3; for (;i++=0;) printf(“%d”,i); }

1 Answers   CSC,


main() { int i=3; switch(i) { default:printf("zero"); case 1: printf("one"); break; case 2:printf("two"); break; case 3: printf("three"); break; } }

1 Answers  


main() { unsigned char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

1 Answers  


const int perplexed = 2; #define perplexed 3 main() { #ifdef perplexed #undef perplexed #define perplexed 4 #endif printf("%d",perplexed); } a. 0 b. 2 c. 4 d. none of the above

1 Answers   emc2, HCL,


main() { extern int i; i=20; printf("%d",i); }

1 Answers   Value Labs,


Categories