#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

what is the code of the output of print the 10 fibonacci number series

2 Answers  


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

1 Answers  


How will u find whether a linked list has a loop or not?

8 Answers   Microsoft,


print numbers till we want without using loops or condition statements like specifically(for,do while, while swiches, if etc)!

11 Answers   Wipro,


In a gymnastic competition, scoring is based on the average of all scores given by the judges excluding the maximum and minimum scores. Let the user input the number of judges, after that, input the scores from the judges. Output the average score. Note: In case, more than two judges give the same score and it happens that score is the maximum or minimum then just eliminate two scores. For example, if the number of judges is 5 and all of them give 10 points each. Then the maximum and minimum score is 10. So the computation would be 10+10+10, this time. The output should be 10 because 30/3 is 10.

0 Answers   TCS,






void main() { int const * p=5; printf("%d",++(*p)); }

3 Answers   Infosys, Made Easy, State Bank Of India SBI,


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

2 Answers  


Program to Delete an element from a doubly linked list.

4 Answers   College School Exams Tests, Infosys,


#define assert(cond) if(!(cond)) \ (fprintf(stderr, "assertion failed: %s, file %s, line %d \n",#cond,\ __FILE__,__LINE__), abort()) void main() { int i = 10; if(i==0) assert(i < 100); else printf("This statement becomes else for if in assert macro"); }

1 Answers  


print a semicolon using Cprogram without using a semicolon any where in the C code in ur program!!

35 Answers   Tata Elxsi, TCS, VI eTrans,


What are segment and offset addresses?

2 Answers   Infosys,


plz tell me the solution.......... in c language program guess any one number from 1 to 50 and tell that number within 8 asking question in yes or no...............

2 Answers   Wipro,


Categories