char* myfunc(char *ptr)
{
ptr+=3;
return(ptr);
}
void main()
{
char *x, *y;
x = "EXAMVEDA";
y = myfunc(x);
printf("y=%s", y);
}
What will be printed when the sample code above is executed?
char* myfunc(char *ptr)
{
ptr+=3;
return(ptr);
}
void main()
{
char *x, *y;
x = "EXAMVEDA";
y = myfunc(x);
printf("y=%s", y);
}A. y=EXAMVEDA
B. y=MVEDA
C. y=VEDA
D. y=EDA
E. y=AMVEDA
Answer: Option B

X = "EXAMVEDA",
when we pass X as argument to function, ptr will be assigned to base address of X. ptr is incremented to 3. means internally till 3rd position of X. means after 0th,1st,2nd positions of string.
i.e at M. from that position on wards we are trying to print in printf("y=%s", y);
How B option come