main()

{

int a=2,*f1,*f2;

f1=f2=&a;

*f2+=*f2+=a+=2.5;

printf("\n%d %d %d",a,*f1,*f2);

}

Answers were Sorted based on User's Feedback



main() { int a=2,*f1,*f2; f1=f2=&a; *f2+=*f2+=a+=2.5; pri..

Answer / odelu vanga

*f2=*f2+(*f=*f2+(a=a+2.5))

a=a+2.5=4
so *f2=4
*f2=*f2+4=8
now *f2=8
so *f2=*f2+8=16

ans:- 16 16 16

Is This Answer Correct ?    18 Yes 3 No

main() { int a=2,*f1,*f2; f1=f2=&a; *f2+=*f2+=a+=2.5; pri..

Answer / susie

Answer :

16 16 16

Explanation:

f1 and f2 both refer to the same memory location a. So
changes through f1 and f2 ultimately affects only the value
of a.

Is This Answer Correct ?    6 Yes 3 No

main() { int a=2,*f1,*f2; f1=f2=&a; *f2+=*f2+=a+=2.5; pri..

Answer / kamlesh meghwal

LOL@Govind Verma....how u r gettin 888..hehe..!!1

Is This Answer Correct ?    3 Yes 0 No

main() { int a=2,*f1,*f2; f1=f2=&a; *f2+=*f2+=a+=2.5; pri..

Answer / forgot_my_name

Since we are modifying same variable three times in the same line (before sequence point ) so we broke the rules, so whatever compiler says would be right..
@Kamlesh Meghwal : In GCC compiler ans is 8 8 8.

Is This Answer Correct ?    1 Yes 0 No

main() { int a=2,*f1,*f2; f1=f2=&a; *f2+=*f2+=a+=2.5; pri..

Answer / vamshikrishna

12 12 12

explanition.
printf takes the last updated value and prints for every var
i.e,

a=a+2.5=4
so f2=4
f2=f2+4=8
here again f2 =4 "since f2=&a"
so f2=f2+4=12

Is This Answer Correct ?    3 Yes 3 No

main() { int a=2,*f1,*f2; f1=f2=&a; *f2+=*f2+=a+=2.5; pri..

Answer / govind verma

but ans is 888 but i dnt know how....

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More C Code Interview Questions

main() { char c; int i = 456; clrscr(); c = i; printf("%d", c); } a. 456 b. -456 c. random number d. none of the above

3 Answers   BrickRed, HCL,


respected sir, i did my MCA in 2013 when i am going to attend to an interview i was asked about my project how will i explain my project could please help me in this and my project title is "Social Networking Site For Social Responsibility"

1 Answers   Genpact, Ozdocs,


#include<stdio.h> main() { int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d----%d",*p,*q); }

1 Answers  


main() { static char names[5][20]={"pascal","ada","cobol","fortran","perl"}; int i; char *t; t=names[3]; names[3]=names[4]; names[4]=t; for (i=0;i<=4;i++) printf("%s",names[i]); }

2 Answers  


#define clrscr() 100 main() { clrscr(); printf("%d\n",clrscr()); }

2 Answers  






Write a complete program that consists of a function that can receive two numbers from a user (M and N) as a parameter. Then print all the numbers between the two numbers including the number itself. If the value of M is smaller than N, print the numbers in ascending flow. If the value of M is bigger than N, print the numbers in descending flow. may i know how the coding look like?

2 Answers  


void main() { static int i=i++, j=j++, k=k++; printf(“i = %d j = %d k = %d”, i, j, k); }

3 Answers  


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

2 Answers   Bosch, eInfochips, HCL, IHCL,


main() { char * strA; char * strB = I am OK; memcpy( strA, strB, 6); } a. Runtime error. b. I am OK c. Compile error d. I am O

4 Answers   HCL,


#include <stdio.h> main() { char * str = "hello"; char * ptr = str; char least = 127; while (*ptr++) least = (*ptr<least ) ?*ptr :least; printf("%d",least); }

1 Answers  


why array index always strats wuth zero?

2 Answers  


main() { char *p = "hello world"; p[0] = 'H'; printf("%s", p); } a. Runtime error. b. “Hello world” c. Compile error d. “hello world”

5 Answers   HCL,


Categories