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

How to return multiple values from a function?

7 Answers  


main() { int a=10,*j; void *k; j=k=&a; j++; k++; printf("\n %u %u ",j,k); }

1 Answers  


main() { char *a = "Hello "; char *b = "World"; clrscr(); printf("%s", strcat(a,b)); } a. Hello b. Hello World c. HelloWorld d. None of the above

3 Answers   HCL,


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,


C program to print magic square of order n where n > 3 and n is odd

2 Answers   Accenture,






main() { char *p="GOOD"; char a[ ]="GOOD"; printf("\n sizeof(p) = %d, sizeof(*p) = %d, strlen(p) = %d", sizeof(p), sizeof(*p), strlen(p)); printf("\n sizeof(a) = %d, strlen(a) = %d", sizeof(a), strlen(a)); }

1 Answers  


main() { signed int bit=512, i=5; for(;i;i--) { printf("%d\n", bit >> (i - (i -1))); } } a. 512, 256, 0, 0, 0 b. 256, 256, 0, 0, 0 c. 512, 512, 512, 512, 512 d. 256, 256, 256, 256, 256

2 Answers   HCL,


main() { int i =0;j=0; if(i && j++) printf("%d..%d",i++,j); printf("%d..%d,i,j); }

1 Answers  


What is wrong with the following code? int *foo() { int *s = malloc(sizeof(int)100); assert(s != NULL); return s; }

1 Answers  


what is the code of the output of print the 10 fibonacci number series

2 Answers  


main() { printf("%d, %d", sizeof('c'), sizeof(100)); } a. 2, 2 b. 2, 100 c. 4, 100 d. 4, 4

18 Answers   HCL, IBM, Infosys, LG Soft, Satyam,


There are 21 people in a room. They have to form groups of 3 people each. How many combinations are possible? Write a C program to print the same.

1 Answers   TCS,


Categories