C Programming - Structures, Unions, Enums - Discussion
Discussion Forum : Structures, Unions, Enums - Point Out Errors (Q.No. 3)
3.
Point out the error in the program?
#include<stdio.h>
int main()
{
struct a
{
float category:5;
char scheme:4;
};
printf("size=%d", sizeof(struct a));
return 0;
}
Answer: Option
Explanation:
Bit field type must be signed int or unsigned int.
The char type: char scheme:4; is also a valid statement.
Discussion:
25 comments Page 2 of 3.
Jayaram said:
1 decade ago
Explain the concept and how it can be useful in progrm and how the value will get signed or unsigned.
Chinni said:
9 years ago
@Professor_X.
You said that sizeof struc is the biggest datatype.
Then what is the size if UNION?
You said that sizeof struc is the biggest datatype.
Then what is the size if UNION?
Shailaja said:
7 years ago
Here, also we can't define a variable of the struct, so without it how we find sizeof struct a?
Vasam sai prathyusha said:
6 years ago
Can anyone explain what is structure padding? and what is the size structure?
Jyoti said:
1 decade ago
Why char scheme:4; is valid ?
Since it is char of 1 byte field.
Since it is char of 1 byte field.
Priya said:
1 decade ago
What is the use of number after category:5 and scheme:4?
Swati said:
1 decade ago
How float category: 5 is wrong? can anyone explain this?
Monisha said:
1 decade ago
What is bit field? explain it in detail.
Rashmi said:
1 decade ago
prashant
very nice explaination...!!
very nice explaination...!!
Amit said:
1 decade ago
What do you mean by un/reserved bits?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers