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
Join The Discussion
Comments ( 2 )
Related Questions on Function
In C, what is a function primarily used for?
A. Decision making
B. Variable declaration
C. Code organization and reusability
D. Printing output
What is the purpose of a function prototype in C?
A. To declare a function's return type
B. To declare a function's name
C. To declare a function's parameters and return type
D. To declare a function's name and parameters
In C, how are function arguments passed by default?
A. By value
B. By reference
C. By pointer
D. By address
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