Examveda
Examveda

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?

A. y=EXAMVEDA

B. y=MVEDA

C. y=VEDA

D. y=EDA

E. y=AMVEDA

Answer: Option B


This Question Belongs to C Program >> Function

Join The Discussion

Comments ( 2 )

  1. Swathi Gowroju
    Swathi Gowroju :
    6 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);

  2. Apoorv Saxena
    Apoorv Saxena :
    6 years ago

    How B option come

Related Questions on Function