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 |
void main() { int i=i++,j=j++,k=k++; printf(“%d%d%d”,i,j,k); }
main() { extern int i; i=20; printf("%d",sizeof(i)); }
main() { int k=1; printf("%d==1 is ""%s",k,k==1?"TRUE":"FALSE"); }
void main() { static int i; while(i<=10) (i>2)?i++:i--; printf(“%d”, i); }
What is the output for the following program main() { int arr2D[3][3]; printf("%d\n", ((arr2D==* arr2D)&&(* arr2D == arr2D[0])) ); }
main() { char *a = "Hello "; char *b = "World"; clrscr(); printf("%s", strcat(a,b)); } a. Hello b. Hello World c. HelloWorld d. None of the above
main() { int i=10,j=20; j = i, j?(i,j)?i:j:j; printf("%d %d",i,j); }
main() { printf("%d", out); } int out=100;
What is the difference between proc means and proc tabulate ? explain with a simple example when you have to use means or tabulate?
what is variable length argument list?
int i,j; for(i=0;i<=10;i++) { j+=5; assert(i<5); }
How will you print % character? a. printf(“\%”) b. printf(“\\%”) c. printf(“%%”) d. printf(“\%%”)