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() { int x=5; clrscr(); for(;x<= 0;x--) { printf("x=%d ", x--); } } a. 5, 3, 1 b. 5, 2, 1, c. 5, 3, 1, -1, 3 d. –3, -1, 1, 3, 5

2 Answers   HCL,


#include<stdio.h> void fun(int); int main() { int a; a=3; fun(a); printf("\n"); return 0; } void fun(int i) { if(n>0) { fun(--n); printf("%d",n); fun(--n); } } the answer is 0 1 2 0..someone explain how the code is executed..?

1 Answers   Wipro,


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,


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

3 Answers  


how to programme using switch statements and fuctions, a programme that will output two even numbers, two odd numbers and two prime numbers of the users chioce.

0 Answers   Mbarara University of Science and Technology,






how to return a multiple value from a function?

2 Answers   Wipro,


void main() { static int i; while(i<=10) (i>2)?i++:i--; printf(“%d”, i); }

2 Answers  


#define SQR(x) x * x main() { printf("%d", 225/SQR(15)); } a. 1 b. 225 c. 15 d. none of the above

3 Answers   HCL,


You are given any character string. Find the number of sets of vowels that come in the order of aeiou in the given string. For eg., let the given string be DIPLOMATIC. The answer returned must be "The number of sets is 2" and "The sets are "IO and AI". Vowels that form a singleton set must be neglected. Try to post the program executable in gcc or g++ or in java.

3 Answers  


Write a function to find the depth of a binary tree.

13 Answers   Adobe, Amazon, EFI, Imagination Technologies,


¦void main() ¦{ ¦int i=10,j; ¦ j=i+++i+++i; ¦printf("%d",j); ¦getch(); ¦} ¦ output:-30 but in same question if we write as- ¦void main() ¦{ ¦int i=10; ¦ int j=i+++i+++i; ¦printf("%d",j); ¦getch(); ¦} ¦ output:-33 why output is changed from 30 to 33. Can any body answer...

3 Answers  


main ( ) { static char *s[ ] = {“black”, “white”, “yellow”, “violet”}; char **ptr[ ] = {s+3, s+2, s+1, s}, ***p; p = ptr; **++p; printf(“%s”,*--*++p + 3); }

1 Answers  


Categories