C Programming :: Pointers - Discussion
Home > C Programming > Pointers > MCQs Questions Discussion
19 / 60
What is the output of the following C Program?
#include<stdio.h>
void main()
{
char *p = "program";
char c;
c = *(++p);
printf("%c",c);
}
#include<stdio.h>
void main()
{
char *p = "program";
char c;
c = *(++p);
printf("%c",c);
}
Ar
Bp
CSegmentation fault
DCompilation Error
ENone of these
Answer: Option (Login/Signup)
Show Explanation
since ,
c=*(++P);
is equivalent to
1. p+=1;// first p will get incremented
2. c=*p;//then the value present at the address stored in p will be assigned into c.
hence c will point to char 'r'.
Asked In ::
STEP-BY-STEP
its correct answer is A. r
since ,
c=*(++P);
is equivalent to
1. p+=1;// first p will get incremented
2. c=*p;//then the value present at the address stored in p will be assigned into c.
hence c will point to char 'r'.
Read Full Answer
Report Error
Please Login First Click Here