C Programming - Structures, Unions, Enums - Discussion
Discussion Forum : Structures, Unions, Enums - Find Output of Program (Q.No. 4)
4.
What will be the output of the program in 16 bit platform (Turbo C under DOS) ?
#include<stdio.h>
int main()
{
struct value
{
int bit1:1;
int bit3:4;
int bit4:4;
}bit;
printf("%d\n", sizeof(bit));
return 0;
}
Answer: Option
Explanation:
Since C is a compiler dependent language, in Turbo C (DOS) the output will be 2, but in GCC (Linux) the output will be 4.
Discussion:
38 comments Page 4 of 4.
Ramya said:
8 years ago
But in bit field we can't apply size of operator.
Then how it is?
Then how it is?
Bhimeswar said:
1 decade ago
@piyush.
Yeah you are definetly correct good explanation.
Yeah you are definetly correct good explanation.
Rohit said:
1 decade ago
@piyush.
How the total number of bits allocated are 9.
How the total number of bits allocated are 9.
Praveen said:
1 decade ago
@Vinay your answer may be 12 according to the concept.
Pranay kantekure said:
9 years ago
Well said @Robert.
Shahid said:
6 years ago
9 bits = 2 bytes.
Abhishek said:
8 years ago
Thanks @Piyush.
Shilpi said:
1 decade ago
Thanks piyush.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers