#include<stdio.h>

main()

{

struct xx

{

int x=3;

char name[]="hello";

};

struct xx *s;

printf("%d",s->x);

printf("%s",s->name);

}

Answers were Sorted based on User's Feedback



#include<stdio.h> main() { struct xx { int x=3; ..

Answer / susie

Answer :

Compiler Error

Explanation:

You should not initialize variables in declaration

Is This Answer Correct ?    10 Yes 3 No

#include<stdio.h> main() { struct xx { int x=3; ..

Answer / anand

Compilation error
you should not iniialize the structure variable inside the
declaration.

Is This Answer Correct ?    4 Yes 2 No

#include<stdio.h> main() { struct xx { int x=3; ..

Answer / rahulkulkarni

There is no syntax error.

Pointer s is declared but never initialized.

Using uninitialized pointer , trying to access members(x and name) of structure results in invalid access of memory.

Hence segmentation fault.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Code Interview Questions

main() { char * strA; char * strB = I am OK; memcpy( strA, strB, 6); } a. Runtime error. b. I am OK c. Compile error d. I am O

4 Answers   HCL,


main() { int i=1; while (i<=5) { printf("%d",i); if (i>2) goto here; i++; } } fun() { here: printf("PP"); }

1 Answers  


In the following pgm add a stmt in the function fun such that the address of 'a' gets stored in 'j'. main(){ int * j; void fun(int **); fun(&j); } void fun(int **k) { int a =0; /* add a stmt here*/ }

1 Answers  


what is brs test reply me email me kashifabbas514@gmail.com

0 Answers  


how to swap 3 nos without using temporary variable

4 Answers   Satyam,






Is this code legal? int *ptr; ptr = (int *) 0x400;

1 Answers  


void main() { void *v; int integer=2; int *i=&integer; v=i; printf("%d",(int*)*v); }

1 Answers   Honeywell,


To Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates.

19 Answers   Amazon, BITS, Microsoft, Syncfusion, Synergy, Vector,


how to check whether a linked list is circular.

11 Answers   Microsoft,


main() { int c = 5; printf("%d", main||c); } a. 1 b. 5 c. 0 d. none of the above

2 Answers   HCL,


void main() { int i=i++,j=j++,k=k++; printf(ā€œ%d%d%dā€,i,j,k); }

1 Answers  


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

9 Answers   CSC, GoDB Tech, IBM,


Categories