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 6 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 ?    15 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

Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like.

21 Answers   ABC, eBay, Goldman Sachs, Google, HUP, Microsoft, TATA,


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().

1 Answers  


Write a prog to accept a given string in any order and flash error if any of the character is different. For example : If abc is the input then abc, bca, cba, cab bac are acceptable, but aac or bcd are unacceptable.

5 Answers   Amazon, Microsoft,


How do you create a really large matrix (i.e. 3500x3500) in C without having the program crash? I can only reach up to 2500. It must have something to do with lack of memory. Please help!

1 Answers  


void main() { static int i; while(i<=10) (i>2)?i++:i--; printf(“%d”, i); }

2 Answers  






main() { unsigned int i=10; while(i-->=0) printf("%u ",i); }

2 Answers   HP,


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  


#define f(g,g2) g##g2 main() { int var12=100; printf("%d",f(var,12)); }

3 Answers  


Sorting entire link list using selection sort and insertion sort and calculating their time complexity

1 Answers   Infosys, Microsoft, NetApp,


how can u draw a rectangle in C

53 Answers   Accenture, CO, Codeblocks, Cognizant, HCL, Oracle, Punjab National Bank, SAP Labs, TCS, University, Wipro,


main() { int i = 3; for (;i++=0;) printf(“%d”,i); }

1 Answers   CSC,


main() { printf("\nab"); printf("\bsi"); printf("\rha"); }

3 Answers  


Categories