What is the output of this program?
void main()
{
struct bitfields {
int bits_1: 2;
int bits_2: 9;
int bits_3: 6;
int bits_4: 1;
}bit;
printf("%d", sizeof(bit));
}
Answer: B
1 byte = 8 bits In the above program we assign 2, 9, 6, 1 for the variables. Sum of the bits assigned is, 2 + 9 + 6 + 1 = 18, It is greater than 2 bytes, so it automatically takes 3 bytes.
Enter details here
All enum constants are?
Answer: B
No answer description available for this question
Enter details here
Predict the output of above program. Assume that the size of an integer is 4 bytes and size of character is 1 byte. Also assume that there is no alignment needed.
union test
{
int x;
char arr[8];
int y;
};
int main()
{
printf("%d", sizeof(union test));
return 0;
}
Answer: C
No answer description available for this question.
Enter details here
What is the output of this program?
#include
int main(){
struct leader
{
char *lead;
int born;
};
struct leader l1 = {"AbdulKalam", 1931};
struct leader l2 = l1;
printf("%s %d", l2.lead, l1.born);
}
Answer: C
We can assign one structure member to the another structure member as like normal variable assignmentation. We can access the same values using different structure variables.
Enter details here
What is the output of this program?
#include
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;
}
Answer: C
No answer description available for this question
Enter details here
Which of the following is a properly defined struct?
Answer: D
No answer description available for this question
Enter details here
What is the correct syntax of enum?
Answer: A
No answer description available for this question
Enter details here
#include
typedef enum{
Male, Female=0
}SEX;
int main()
{
SEX var = Male;
SEX var1 = Female;
printf("%d %d",var, var1);
return 0;
}
Answer: A
No answer description available for this que
Enter details here
What is the output of this C code?
#include
struct student
{
int no;
char name[20];
}
void main()
{
struct student s;
s.no = 8;
printf("hello");
}
Answer: A
No answer description available for this question.
Enter details here
Pick the incorrect statement with respect to enums.
Answer: A
The statement that two enum symbols cannot have the same value is incorrect. Any number of enum symbols can have the same value.
Enter details here