ExamVeda
Login
Home
This question belongs to C Program Function
Function
?

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?

Answer & Solution
Correct Answer: Option B
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

2 Comments
Swathi Gowroju
Swathi Gowroju 9 years ago
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);
Apoorv Saxena
Apoorv Saxena 9 years ago
How B option come