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

void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }

2 Answers  


Find the largest number in a binary tree

7 Answers   Infosys,


# include <stdio.h> int one_d[]={1,2,3}; main() { int *ptr; ptr=one_d; ptr+=3; printf("%d",*ptr); }

1 Answers  


writte a c-programm to display smill paces

2 Answers  


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

2 Answers  






What is the difference between proc means and proc tabulate ? explain with a simple example when you have to use means or tabulate?

1 Answers  


void main() { int i=i++,j=j++,k=k++; printf(“%d%d%d”,i,j,k); }

1 Answers  


How will you print % character? a. printf(“\%”) b. printf(“\\%”) c. printf(“%%”) d. printf(“\%%”)

4 Answers   HCL,


main() { int i=400,j=300; printf("%d..%d"); }

3 Answers  


void main() { unsigned giveit=-1; int gotit; printf("%u ",++giveit); printf("%u \n",gotit=--giveit); }

1 Answers  


There were 10 records stored in “somefile.dat” but the following program printed 11 names. What went wrong? void main() { struct student { char name[30], rollno[6]; }stud; FILE *fp = fopen(“somefile.dat”,”r”); while(!feof(fp)) { fread(&stud, sizeof(stud), 1 , fp); puts(stud.name); } }

1 Answers  


Code for 1>"ascii to string" 2>"string to ascii"

1 Answers   Aricent, Global Logic,


Categories