Structure and Union - C programming (MCQ)
31. What is the output of this program?
#include <stdio.h>
struct employee
{
char *empname;
int salary;
};
int main()
{
struct employee e, e1;
e.empname = "Sridhar";
e1 = e;
printf("%s %s", e.empname, e1.empname);
return 0;
}
View Answer
32. What is the output of this program?
#include <stdio.h>
struct student
{
int no = 5;
char name[20];
};
void main()
{
struct student s;
s.no = 8;
printf("hello");
}
View Answer
33. What is the output of this program?
#include <stdio.h>
void main()
{
struct number
{
int no;
char name[20];
};
struct number s;
s.no = 50;
printf("%d", s.no);
}
View Answer
34. Number of bytes in memory taken by the below structure is
#include <stdio.h>
struct test
{
int k;
char c;
};
View Answer
35. What is the output of this program?
#include <stdio.h>
struct student
{
char *c;
};
void main()
{
struct student s[2];
printf("%d", sizeof(s));
}
View Answer
36. Which of the following are incorrect syntax for pointer to structure?
(Assuming struct temp{int b;}*my_struct;)
View Answer
37. Which of the following is an incorrect syntax to pass by reference a member of a structure in a function?
(Assume: struct temp{int a;}s;)
View Answer
38. For the following function call which option is not possible?
func(&s.a); //where s is a variable of type struct and a is the member of the struct.
View Answer
39. The correct syntax to access the member of the ith structure in the array of structures is?
Assuming:
struct temp
{
int b;
}s[50];
View Answer
40. The number of distinct nodes the following struct declaration can point to is
struct node
{
struct node *left;
struct node *centre;
struct node *right;
};
View Answer
Also check :