why the option is C ? please explain
Did not understand MCQ 1
Please paste the question here so that i can check.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
Q1
What will be the output of the following code? #include<stdio.h>
void main(){
char *p;
char sample_string[]=“codingjunction”;
p=sample_string;
p +=6;
printf("%s",p); }
A) coding
B) codingj
C) junction
D) codingjunction
Answer must be C
p will contain the string “codingjunction”
When you just refer to p…it means it is the base address of the character array
So p+=6…means 6 position ahead of the base address…
So now base address p…is the address where j is there.
printf("%s",p); Now this will print the remaining string from j ie. junction