main()
{
char *p="hai friends",*p1;
p1=p;
while(*p!='\0') ++*p++;
printf("%s %s",p,p1);
}
Answers were Sorted based on User's Feedback
Answer / susie
Answer :
ibj!gsjfoet
Explanation:
++*p++ will be parse in the given order
> *p that is value at the location currently pointed by p
will be taken
> ++*p the retrieved value will be incremented
> when ; is encountered the location will be incremented
that is p++ will be executed
Hence, in the while loop initial value pointed by p is ‘h’,
which is changed to ‘i’ by executing ++*p and pointer moves
to point, ‘a’ which is similarly changed to ‘b’ and so on.
Similarly blank space is converted to ‘!’. Thus, we obtain
value in p becomes “ibj!gsjfoet” and since p reaches ‘\0’
and p1 points to p thus p1doesnot print anything.
| Is This Answer Correct ? | 6 Yes | 1 No |
Answer / sourav punoriyar
checked in gcc.
it gives segmentation fault(core dump),in gcc...
because the char *p="hai friends",is a pointer pointing to
this string in the code section,(this string is present in
code section.)
now,
++*p=this is ++(*p)=h+1=i,and stores it in p,but data in
code section cannot be modified so core dump.
if
*p++,first dereference and then increases the pointer....so
it will point to a now.
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / sourav punoriyar
but in turbo c it can be the given ans ,as given by susie,
as there it gets stored in datasection which is modifiable
| Is This Answer Correct ? | 1 Yes | 0 No |
main ( ) { static char *s[ ] = {“black”, “white”, “yellow”, “violet”}; char **ptr[ ] = {s+3, s+2, s+1, s}, ***p; p = ptr; **++p; printf(“%s”,*--*++p + 3); }
how can u draw a rectangle in C
53 Answers Accenture, CO, Codeblocks, Cognizant, HCL, Oracle, Punjab National Bank, SAP Labs, TCS, University, Wipro,
Write a program to model an exploding firecracker in the xy plane using a particle system
main() { char *p; int *q; long *r; p=q=r=0; p++; q++; r++; printf("%p...%p...%p",p,q,r); }
abcdedcba abc cba ab ba a a
Link list in reverse order.
main() { char *p = "hello world"; p[0] = 'H'; printf("%s", p); } a. Runtime error. b. “Hello world” c. Compile error d. “hello world”
main() { char p[ ]="%d\n"; p[1] = 'c'; printf(p,65); }
main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf(" %d ",*c); ++q; } for(j=0;j<5;j++){ printf(" %d ",*p); ++p; } }
main() { unsigned char i=0; for(;i>=0;i++) ; printf("%d\n",i); }
how to programme using switch statements and fuctions, a programme that will output two even numbers, two odd numbers and two prime numbers of the users chioce.
0 Answers Mbarara University of Science and Technology,
char *someFun() { char *temp = “string constant"; return temp; } int main() { puts(someFun()); }