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

main() { int i; clrscr(); printf("%d", &i)+1; scanf("%d", i)-1; } a. Runtime error. b. Runtime error. Access violation. c. Compile error. Illegal syntax d. None of the above

1 Answers   HCL,


how to return a multiple value from a function?

5 Answers   Wipro,


write a program in c to merge two array

2 Answers  


In the following pgm add a stmt in the function fun such that the address of 'a' gets stored in 'j'. main(){ int * j; void fun(int **); fun(&j); } void fun(int **k) { int a =0; /* add a stmt here*/ }

1 Answers  


Sorting entire link list using selection sort and insertion sort and calculating their time complexity

1 Answers   Infosys, Microsoft, NetApp,






Write out a function that prints out all the permutations of a string. For example, abc would give you abc, acb, bac, bca, cab, cba. You can assume that all the characters will be unique.

5 Answers   IITR, Microsoft, Nike,


char *someFun1() { char temp[ ] = “string"; return temp; } char *someFun2() { char temp[ ] = {‘s’, ‘t’,’r’,’i’,’n’,’g’}; return temp; } int main() { puts(someFun1()); puts(someFun2()); }

2 Answers  


main( ) { int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}}; printf(“%u %u %u %d \n”,a,*a,**a,***a); printf(“%u %u %u %d \n”,a+1,*a+1,**a+1,***a+1); }

2 Answers  


Is the following code legal? struct a { int x; struct a b; }

1 Answers  


write a program to Insert in a sorted list

4 Answers   Microsoft,


write a program to find out roots of quadratic equation "x=-b+-(b^2-4ac0^-1/2/2a"

2 Answers  


int i=10; main() { extern int i; { int i=20; { const volatile unsigned i=30; printf("%d",i); } printf("%d",i); } printf("%d",i); }

1 Answers  


Categories