main()

{

int i=300;

char *ptr = &i;

*++ptr=2;

printf("%d",i);

}

Answers were Sorted based on User's Feedback



main() { int i=300; char *ptr = &i; *++ptr=2; printf(&quo..

Answer / susie

Answer :

556

Explanation:

The integer value 300 in binary notation is: 00000001
00101100. It is stored in memory (small-endian) as:
00101100 00000001. Result of the expression *++ptr = 2 makes
the memory representation as: 00101100 00000010. So the
integer corresponding to it is 00000010 00101100 => 556.

Is This Answer Correct ?    77 Yes 8 No

main() { int i=300; char *ptr = &i; *++ptr=2; printf(&quo..

Answer / subrat

556

Is This Answer Correct ?    23 Yes 5 No

main() { int i=300; char *ptr = &i; *++ptr=2; printf(&quo..

Answer / giri

cannot convert int * to char * in main

Is This Answer Correct ?    14 Yes 12 No

main() { int i=300; char *ptr = &i; *++ptr=2; printf(&quo..

Answer / bidhu

I think the answer depends on compiler.

In Dev-C++ the result is cannot convert int* to char* error

In Code:Block it gives a warning but gives the result 556

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More C Code Interview Questions

Which version do you prefer of the following two, 1) printf(ā€œ%sā€,str); // or the more curt one 2) printf(str);

1 Answers  


#include<stdio.h> main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s=malloc(sizeof(struct xx)); printf("%d",s->x); printf("%s",s->name); }

1 Answers   TCS,


Is the following code legal? typedef struct a aType; struct a { int x; aType *b; };

1 Answers  


what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d ",i++,i--,++i,--i,i); }

10 Answers  


void main() { void *v; int integer=2; int *i=&integer; v=i; printf("%d",(int*)*v); }

1 Answers   Honeywell,






struct Foo { char *pName; char *pAddress; }; main() { struct Foo *obj = malloc(sizeof(struct Foo)); clrscr(); obj->pName = malloc(100); obj->pAddress = malloc(100); strcpy(obj->pName,"Your Name"); strcpy(obj->pAddress, "Your Address"); free(obj); printf("%s", obj->pName); printf("%s", obj->pAddress); } a. Your Name, Your Address b. Your Address, Your Address c. Your Name Your Name d. None of the above

2 Answers   HCL,


Write, efficient code for extracting unique elements from a sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).

13 Answers   Intel, Microsoft, TCS,


write a program to count the number the same (letter/character foreg: 's') in a given sentence.

2 Answers  


main() { show(); } void show() { printf("I'm the greatest"); }

2 Answers  


void main() { char a[]="12345\0"; int i=strlen(a); printf("here in 3 %d\n",++i); }

3 Answers  


PROG. TO PRODUCE 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1

1 Answers  


what is brs test reply me email me kashifabbas514@gmail.com

0 Answers  


Categories