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

main() { int i = 0xff ; printf("\n%d", i<<2); } a. 4 b. 512 c. 1020 d. 1024

2 Answers   HCL,


main() { int i=4,j=7; j = j || i++ && printf("YOU CAN"); printf("%d %d", i, j); }

1 Answers  


posted by surbhi just now main() { float a = 5.375; char *p; int i; p=(char*)&a; for(i=0;i<=3;i++) printf("%02x",(unsigned char) p[i]); } how is the output of this program is :: 0000ac40 please let me know y this output has come

2 Answers   GATE,


main() { int i, n; char *x = “girl”; n = strlen(x); *x = x[n]; for(i=0; i<n; ++i) { printf(“%s\n”,x); x++; } }

2 Answers  


void main() { while(1){ if(printf("%d",printf("%d"))) break; else continue; } }

1 Answers  






&#8206;#define good bad main() { int good=1; int bad=0; printf ("good is:%d",good); }

2 Answers  


why the range of an unsigned integer is double almost than the signed integer.

1 Answers  


What is the output for the following program main() { int arr2D[3][3]; printf("%d\n", ((arr2D==* arr2D)&&(* arr2D == arr2D[0])) ); }

1 Answers  


#include<stdio.h> void fun(int); int main() { int a; a=3; fun(a); printf("\n"); return 0; } void fun(int i) { if(n>0) { fun(--n); printf("%d",n); fun(--n); } } the answer is 0 1 2 0..someone explain how the code is executed..?

1 Answers   Wipro,


#define square(x) x*x main() { int i; i = 64/square(4); printf("%d",i); }

4 Answers   Google, HCL, Quick Heal, WTF,


union u { union u { int i; int j; }a[10]; int b[10]; }u; main() { printf("\n%d", sizeof(u)); printf(" %d", sizeof(u.a)); // printf("%d", sizeof(u.a[4].i)); } a. 4, 4, 4 b. 40, 4, 4 c. 1, 100, 1 d. 40 400 4

3 Answers   HCL,


char inputString[100] = {0}; To get string input from the keyboard which one of the following is better? 1) gets(inputString) 2) fgets(inputString, sizeof(inputString), fp)

1 Answers  


Categories