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

main() { char *str1="abcd"; char str2[]="abcd"; printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd")); }

1 Answers  


Extend the sutherland-hodgman clipping algorithm to clip three-dimensional planes against a regular paralleiepiped

1 Answers   IBM,


There are 21 people in a room. They have to form groups of 3 people each. How many combinations are possible? Write a C program to print the same.

1 Answers   TCS,


Write a program to receive an integer and find it's octal equivalent. How can i do with using while loop.

2 Answers  


How to swap two variables, without using third variable ?

104 Answers   AB, ADP, BirlaSoft, Cisco, Cygnet Infotech, HCL, Hewitt, Honeywell, HP, IBM, Infosys, Manhattan, Microsoft, Mobius, Percept, Satyam, SofTMware, TCS, Wipro, Yamaha,






What are the files which are automatically opened when a C file is executed?

1 Answers  


main() { extern i; printf("%d\n",i); { int i=20; printf("%d\n",i); } }

1 Answers  


#include<conio.h> main() { int x,y=2,z,a; if(x=y%2) z=2; a=2; printf("%d %d ",z,x); }

1 Answers  


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.

2 Answers  


how to swap 3 nos without using temporary variable

4 Answers   Satyam,


main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }

9 Answers   CSC, GoDB Tech, IBM,


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); }

1 Answers  


Categories