Interview Questions

What will be printed as the result of the operation below

C Interview Questions and Answers


(Continued from previous question...)

What will be printed as the result of the operation below <..

What will be printed as the result of the operation below:
main()
{
char *ptr = ” Cisco Systems”;
*ptr++; printf(“%s\n”,ptr)
; ptr++;
printf(“%s\n”,ptr);

}



1) ptr++ increments the ptr address to point to the next address. In the prev example, ptr was pointing to the space in the string before C, now it will point to C.

2)*ptr++ gets the value at ptr++, the ptr is indirectly forwarded by one in this case.

3)(*ptr)++ actually increments the value in the ptr location. If *ptr contains a space, then (*ptr)++ will now contain an exclamation mark.

Answer:Cisco Systems

(Continued on next question...)

Other Interview Questions