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
Kindly explain this
hi @vanshikasharma1645
p is a character pointer.
p = sample_string;
through this statement, p will point to the 0th element of the string
p+=6
this statement, through pointer arithmetics will make p point at the 6th index of the string
so if you print p, the string will be printed from that index onwards
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.