main()
{
char *p = “ayqm”;
printf(“%c”,++*(p++));
}
Answers were Sorted based on User's Feedback
Answer / nithin
p has address of letter a. p++ means it will have address of
y. *p reffers to the character y. so pre-incrementing that
will result in letter z being printed.
Is This Answer Correct ? | 19 Yes | 18 No |
Answer / kishor amballi
char *p = "ayqm";
this line points to a string which is in read only data segment.
the printf statement p++ will be pointing to y.
It dumps core when trying to assign z at that location because the memory pointed to string ayqm is READ ONLY.
Is This Answer Correct ? | 4 Yes | 4 No |
Answer / govind verma
output will be error because p is a character pointer point to a constant string we cant modified it and in above program we try to modified at ++*(p++) ..so its lead to be error constatnt cant be modified......
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / mayank srivastava
printf("%c", p );-----> prints address of a, i.e. 1024 (say).
printf("%c", p++);-----> prints address of y, i.e. 1025 (say)
printf("%c", *(p++));-----> prints the char y,
printf("%c", ++*(p++));-----> prints the char z,
so final answer is z.
Is This Answer Correct ? | 2 Yes | 5 No |
why java is platform independent?
main() { int x=5; for(;x!=0;x--) { printf("x=%d\n", x--); } } a. 5, 4, 3, 2,1 b. 4, 3, 2, 1, 0 c. 5, 3, 1 d. none of the above
main() { { unsigned int bit=256; printf("%d", bit); } { unsigned int bit=512; printf("%d", bit); } } a. 256, 256 b. 512, 512 c. 256, 512 d. Compile error
main() { char *p = “ayqm”; printf(“%c”,++*(p++)); }
29 Answers IBM, TCS, UGC NET, Wipro,
Write a program that reads a dynamic array of 40 integers and displays only even integers
void pascal f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } void cdecl f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } main() { int i=10; f(i++,i++,i++); printf(" %d\n",i); i=10; f(i++,i++,i++); printf(" %d",i); }
func(a,b) int a,b; { return( a= (a==b) ); } main() { int process(),func(); printf("The value of process is %d !\n ",process(func,3,6)); } process(pf,val1,val2) int (*pf) (); int val1,val2; { return((*pf) (val1,val2)); }
main() { register int a=2; printf("Address of a = %d",&a); printf("Value of a = %d",a); }
which function is used to clear the buffer stream on gcc? for example: I wrote following code on gcc #include<stdio.h> int main(void) { char ch; int a,b; printf("\nenter two numbers:\t"); scanf("%d%d",&a,&b); printf("enter number is %d and %d",a,b); printf("\nentercharacter:\t"); scanf("%c",&ch); printf("enter character is %c",ch); return 0; } in above progarm ch could not be scan. why?plz tell me solution.
why the range of an unsigned integer is double almost than the signed integer.
void main() { int i=5; printf("%d",i+++++i); }
Write a Program in 'C' To Insert a Unique Number Only. (Hint: Just Like a Primary Key Numbers In Database.) Please Some One Suggest Me a Better Solution for This question ??