void main()

{

int *i = 0x400; // i points to the address 400

*i = 0; // set the value of memory location pointed by i;

}

Answers were Sorted based on User's Feedback



void main() { int *i = 0x400; // i points to the address 400 *i = 0; //..

Answer / amit kumar kunwar

as i is pointing to the address 400 and getting assigned a value of 0. this code is working perfectly. hence the Output is 0 for this code.

Is This Answer Correct ?    1 Yes 0 No

void main() { int *i = 0x400; // i points to the address 400 *i = 0; //..

Answer / susie

Answer :

Undefined behavior

Explanation:

The second statement results in undefined behavior because
it points to some location whose value may not be available
for modification. This type of pointer in which the
non-availability of the implementation of the referenced
location is known as 'incomplete type'.

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C Code Interview Questions

int i; main(){ int t; for ( t=4;scanf("%d",&i)-t;printf("%d\n",i)) printf("%d--",t--); } // If the inputs are 0,1,2,3 find the o/p

2 Answers  


What is the main difference between STRUCTURE and UNION?

13 Answers   HCL,


Write a program that reads a dynamic array of 40 integers and displays only even integers

2 Answers  


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

1 Answers  


write a c-program to display the time using FOR loop

3 Answers   HCL,






Give a one-line C expression to test whether a number is a power of 2.

10 Answers   Microsoft,


typedef struct error{int warning, error, exception;}error; main() { error g1; g1.error =1; printf("%d",g1.error); }

1 Answers  


Write a C program to print look and say sequence? For example if u get the input as 1 then the sequence is 11 21 1211 111221 312211 12112221 .......(it counts the no. of 1s,2s etc which is in successive order) and this sequence is used in run-length encoding.

1 Answers  


main() { int i=300; char *ptr = &i; *++ptr=2; printf("%d",i); }

4 Answers   CSC,


how can u draw a rectangle in C

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


Give a very good method to count the number of ones in a 32 bit number. (caution: looping through testing each bit is not a solution)

7 Answers   Microsoft,


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

1 Answers   Infosys, Microsoft, NetApp,


Categories