main()

{

char *p = “ayqm”;

printf(“%c”,++*(p++));

}

Answers were Sorted based on User's Feedback



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

Answer / nithin

p has address of letter a. p++ means it will have address of
y. *p reffers to the character y. so pre-incrementing that
will result in letter z being printed.

Is This Answer Correct ?    19 Yes 18 No

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

Answer / minati sahoo

z

Is This Answer Correct ?    50 Yes 50 No

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

Answer / kishor amballi

char *p = "ayqm";

this line points to a string which is in read only data segment.

the printf statement p++ will be pointing to y.
It dumps core when trying to assign z at that location because the memory pointed to string ayqm is READ ONLY.

Is This Answer Correct ?    4 Yes 4 No

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

Answer / purushotham

baso

Is This Answer Correct ?    4 Yes 5 No

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

Answer / mr. c

Segmentation fault (core dumped)

Is This Answer Correct ?    6 Yes 8 No

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

Answer / hayat

compil time error

Is This Answer Correct ?    5 Yes 7 No

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

Answer / manoj gupta

function "printf" should have a prototype

Is This Answer Correct ?    4 Yes 6 No

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

Answer / govind verma

output will be error because p is a character pointer point to a constant string we cant modified it and in above program we try to modified at ++*(p++) ..so its lead to be error constatnt cant be modified......

Is This Answer Correct ?    0 Yes 2 No

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

Answer / mayank srivastava

printf("%c", p );-----> prints address of a, i.e. 1024 (say).
printf("%c", p++);-----> prints address of y, i.e. 1025 (say)
printf("%c", *(p++));-----> prints the char y,
printf("%c", ++*(p++));-----> prints the char z,

so final answer is z.

Is This Answer Correct ?    2 Yes 5 No

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

Answer / l.harish

infinite loop

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More C Code Interview Questions

¦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  


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() { int y; scanf("%d",&y); // input given is 2000 if( (y%4==0 && y%100 != 0) || y%100 == 0 ) printf("%d is a leap year"); else printf("%d is not a leap year"); }

1 Answers  


void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }

2 Answers  


Write a c program to search an element in an array using recursion

1 Answers   Wipro,






what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d ",i++,i--,++i,--i,i); }

10 Answers  


main() { int a[10]; printf("%d",*a+1-*a+3); }

1 Answers  


Give a very good method to count the number of ones in a 32 bit number. (caution: looping through testing each bit is not a solution)

7 Answers   Microsoft,


union u { struct st { int i : 4; int j : 4; int k : 4; int l; }st; int i; }u; main() { u.i = 100; printf("%d, %d, %d",u.i, u.st.i, u.st.l); } a. 4, 4, 0 b. 0, 0, 0 c. 100, 4, 0 d. 40, 4, 0

1 Answers   HCL,


Write a program to receive an integer and find its octal equivalent?

7 Answers  


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

1 Answers   Zoho,


4. Main() { Int i=3,j=2,c=0,m; m=i&&j||c&I; printf(“%d%d%d%d”,I,j,c,m); }

2 Answers   Broadridge,


Categories