71. What will be the output of the following C code?
#include <stdio.h>
union p
{
int x;
char y;
}k = {1, 97};
int main()
{
printf("%d\n", k.y);
}
#include <stdio.h>
union p
{
int x;
char y;
}k = {1, 97};
int main()
{
printf("%d\n", k.y);
}
72. What will be the output of the following C code?
#include <stdio.h>
typedef struct p *q;
struct p
{
int x;
char y;
q ptr;
};
int main()
{
struct p p = {1, 2, &p};
printf("%d\n", p.ptr->x);
return 0;
}
#include <stdio.h>
typedef struct p *q;
struct p
{
int x;
char y;
q ptr;
};
int main()
{
struct p p = {1, 2, &p};
printf("%d\n", p.ptr->x);
return 0;
}
73. Which operator connects the structure name to its member name?
74. Which of the following may create problem in the typedef program?
75. What will be the output of the following C code?
#include <stdio.h>
struct point
{
int x;
int y;
};
void foo(struct point*);
int main()
{
struct point p1[] = {1, 2, 3, 4};
foo(p1);
}
void foo(struct point p[])
{
printf("%d\n", p->x);
}
#include <stdio.h>
struct point
{
int x;
int y;
};
void foo(struct point*);
int main()
{
struct point p1[] = {1, 2, 3, 4};
foo(p1);
}
void foo(struct point p[])
{
printf("%d\n", p->x);
}
76. What will be the output of the following C code?
#include <stdio.h>
struct temp
{
int a;
} s;
void change(struct temp);
main()
{
s.a = 10;
change(s);
printf("%d\n", s.a);
}
void change(struct temp s)
{
s.a = 1;
}
#include <stdio.h>
struct temp
{
int a;
} s;
void change(struct temp);
main()
{
s.a = 10;
change(s);
printf("%d\n", s.a);
}
void change(struct temp s)
{
s.a = 1;
}
77. What will be the output of the following C code?
#include <stdio.h>
struct student
{
char *name;
};
struct student s[2];
void main()
{
s[0].name = "alan";
s[1] = s[0];
printf("%s%s", s[0].name, s[1].name);
s[1].name = "turing";
printf("%s%s", s[0].name, s[1].name);
}
#include <stdio.h>
struct student
{
char *name;
};
struct student s[2];
void main()
{
s[0].name = "alan";
s[1] = s[0];
printf("%s%s", s[0].name, s[1].name);
s[1].name = "turing";
printf("%s%s", s[0].name, s[1].name);
}
78. What will be the output of the following C code?
#include <stdio.h>
struct p
{
int x;
char y;
};
void foo(struct p* );
int main()
{
typedef struct p* q;
struct p p1[] = {1, 92, 3, 94, 5, 96};
foo(p1);
}
void foo(struct p* p1)
{
q ptr1 = p1;
printf("%d\n", ptr1->x);
}
#include <stdio.h>
struct p
{
int x;
char y;
};
void foo(struct p* );
int main()
{
typedef struct p* q;
struct p p1[] = {1, 92, 3, 94, 5, 96};
foo(p1);
}
void foo(struct p* p1)
{
q ptr1 = p1;
printf("%d\n", ptr1->x);
}
79. Which algorithm is used for searching in the table?
80. What is the correct syntax to initialize bit-fields in an structure?
Read More Section(Structure and Union)
Each Section contains maximum 100 MCQs question on Structure and Union. To get more questions visit other sections.