main()
{
int i, n;
char *x = “girl”;
n = strlen(x);
*x = x[n];
for(i=0; i<n; ++i)
{
printf(“%s\n”,x);
x++;
}
}
Answers were Sorted based on User's Feedback
Answer / susie
Answer :
(blank space)
irl
rl
l
Explanation:
Here a string (a pointer to char) is initialized with a
value “girl”. The strlen function returns the length of the
string, thus n has a value 4. The next statement assigns
value at the nth location (‘\0’) to the first location. Now
the string becomes “\0irl” . Now the printf statement prints
the string after each iteration it increments it starting
position. Loop starts from 0 to 4. The first time x[0] =
‘\0’ hence it prints nothing and pointer value is
incremented. The second time it prints from x[1] i.e “irl”
and the third time it prints “rl” and the last time it
prints “l” and the loop terminates.
Is This Answer Correct ? | 8 Yes | 3 No |
main( ) { void *vp; char ch = ‘g’, *cp = “goofy”; int j = 20; vp = &ch; printf(“%c”, *(char *)vp); vp = &j; printf(“%d”,*(int *)vp); vp = cp; printf(“%s”,(char *)vp + 3); }
void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }
Develop a routine to reflect an object about an arbitrarily selected plane
main() { int i=1; while (i<=5) { printf("%d",i); if (i>2) goto here; i++; } } fun() { here: printf("PP"); }
what is oop?
main() { char name[10],s[12]; scanf(" \"%[^\"]\"",s); } How scanf will execute?
What is your nationality?
#include<stdio.h> int main() { int a=3,post,pre; post= a++ * a++ * a++; a=3; pre= ++a * ++a * ++a; printf("post=%d pre=%d",post,pre); return 0; }
void main() { int c; c=printf("Hello world"); printf("\n%d",c); }
int main() { int x=10; printf("x=%d, count of earlier print=%d", x,printf("x=%d, y=%d",x,--x)); getch(); } ================================================== returns error>> ld returned 1 exit status =================================================== Does it have something to do with printf() inside another printf().
void main() { int i=10, j=2; int *ip= &i, *jp = &j; int k = *ip/*jp; printf(“%d”,k); }
Program to Delete an element from a doubly linked list.
4 Answers College School Exams Tests, Infosys,