Showing posts with label structures. Show all posts
Showing posts with label structures. Show all posts

Thursday, 12 January 2012

Frequently Asked Questions in Technical Round at MNCs like TCS, WIPRO, INFOSYS,..etc – 3

Predict the output or error(s) for the following:


1)

#include<stdio.h>

main()

{

struct xx


{


int x=3;


char name[]="hello";


};


struct xx *s=malloc(sizeof(struct xx));


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


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


}

Answer:

Compiler Error


Explanation:

Wednesday, 16 November 2011

Predict the output or error(s) for the following:

 #include<stdio.h>

main()

{

struct xx


{


int x;


struct yy


{


char s;


 struct xx *p;


};


struct yy *q;


};


}

Answer:

Compiler Error


Explanation:

Friday, 11 November 2011

Predict the output or error(s) for the following:

#include<stdio.h>

main()

{

struct xx


{


      int x=3;


      char name[]="hello";


 };


struct xx *s;


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


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


}

Answer:

Compiler Error


Explanation: