Character Array MCQ 10 : Assigning (String + Integer) Format to Variable
Character Array MCQ 10 : Assigning (String + Integer) Format to Variable
What is the Output of the Following Program ?
#include<stdio.h> #include<string.h> void main() { char *str=1+"Pritesh"; printf(str+1); }
Options :
- Pritesh
- ritesh
- itesh
- Incorrect Declaration
Output:
Switch to String MCQ Home : Click Here
How and Why ?
- *str is Pointer Variable and AddressOf(1+”Pritesh”) is Assigned to Pointer Variable
- It Tells that Address of “r” is Assigned as “Starting / Base Address”
- Refer : Here to Learn How to Solve printf(1+”%d”) type Problems ?.
- So Initially “ritesh” is Assigned to String Type Variable.
*str = "ritesh"
- Before Printing “str + 1″ prints “itesh”