{
int ecode;
struct employ *e;
};
Example
- Error: in structure declaration
- Linker
- No error
- None of the above
The correct option is (c).
Explanation:
This type of declaration is known as self-referential structure. This type of declaration is allowed to be used in a program.
Here *e is the pointer to a struct employ.
Therefore the compiler will return No error in a program
## 17) The Bit fields cannot be used in a union.
- True
- False
The correct option is (b).
Explanation:
False, the bit fields are allowed to be used inside a union.
The C program using bit fields inside a union is given below:
include<stdio.h>
union Pointer
{
unsigned int a:4;
unsigned int b:4;
int res;
};
int main
{
union Pointer pt;
pt.a = 2;
pt.b = 6;
pt.res = pt.b;
printf("\n The value of res is: %d" , pt.res);
return 0;
}
// Output: The value of res is: 6
Example
## 18) The union elements can be of different sizes.
- True
- False
The correct option is (a).
Explanation:
True, the union element can be of different sizes.
All the union elements may have different sizes but they share the common space of memory.
## 19) If the below structure is used for writing into a file using fwrite(), can fread() read it back successfully?
struct employ
{
char *p;
int age;
};
struct employ e={"javaLogic Practice", 25};
FILE *fp;
fwrite(&e, sizeof(e), 1, fp);
Example
The correct option is (b).
Explanation:
No, because the structure in a program contain a char pointer while writing the structure to the disk using fwrite() only the data stored in pointer 'n' will get written. Hence the fread() fails to read the data stored in pointer.
Therefore the fread() cannot read it back successfully.
## 20) What will be the output of a program in Turbo C under DOS (16 bit platform)?
include<stdio.h>
int main
{
struct values
{
int bit1:1;
int bit3:3;
int bit4:4;
}bit;
printf("%d \n", sizeof(bit));
return 0;
}
Example
The correct option is (c).
Explanation:
Due to its dependency on the machine or compiler, the C language in Turbo C (DOS) assigns a size of 2 to the integer data type.
Thus, executing the code printf("%d \n", sizeof(bit)); will display the number 2 as its output.