What is the output of this C code?

			  		

Loading

Practice Structures, Unions, Enums – What is the output of this C code?


#include
typedef struct p *q;
struct p
{
int x; char y; q ptr;
};
int main()
{
struct p p = {1, 2, &p};
printf("%d
", p.ptr->ptr->x);
return 0;
}

Which of the following uses structure?

Loading

Practice Structures, Unions, Enums – Which of the following uses structure?

Consider the following declaration

enum color {black= -1,

Loading

Practice Structures, Unions, Enums – Consider the following declaration

enum color {black= -1, blue, green};
This represents

Most appropriate sentence to describe unions is

Loading

Practice Structures, Unions, Enums – Most appropriate sentence to describe unions is

The below declaration



			  		

Loading

Practice Structures, Unions, Enums – The below declaration


union id {

char color [12];

int size;

} tshirt, pant;


denotes shirt and pant are variable of type id and

Consider the following declaration


Loading

Practice Structures, Unions, Enums – Consider the following declaration


struct list {

int x;

struct list *next;

)*head;


The statement head.x = 100

What is the output of the following program ?


Loading

Practice Structures, Unions, Enums – What is the output of the following program ?


#include

void main()

{

struct xx

{

int x=3;

char name[]="hello";

};

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

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

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

}

What is the output of the following problem ?

Loading

Practice Structures, Unions, Enums – What is the output of the following problem ?


#include

struct {
int x;
int y;
union {
int id_no;
char *name;
}b;
}s,*st;
int main()
{
st = &s;
st->x=10;
st->b.id_no = 101;
printf("%d %d
",s.x,s.b.id_no);
return 0;
}

What is the output of the following program ?

Loading

Practice Structures, Unions, Enums – What is the output of the following program ?


#include
int main() {
union {
int a;
int b;
int c;
} u,v;
u.a = 10;
u.b = 20;
printf("%d %d
",u.a,u.b);
return 0;
}

What will be output of the following “c” code?


Loading

Practice Structures, Unions, Enums – What will be output of the following “c” code?


#include

enum color{BLACK, BLUR, GREEN};

void main()

{

printf("%d %d %d", BLACK, BLUR, GREEN);

}

How do you modify the below structure to have less size in view of byt

Loading

Practice Structures, Unions, Enums – How do you modify the below structure to have less size in view of byte padding?


typedef struct emp
{
int emp_code;
char* emp_name;
char grade;
double salary;
char gender;
struct emp* link;
}employee;

What is the output of the following program ?


Loading

Practice Structures, Unions, Enums – What is the output of the following program ?


#include

void main()

{

struct xx

{

int x=3;

char name[]="hello";

};

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

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

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

}