Saturday, January 28, 2012

struct bit fields questions in c





struct bit fields questions answers
and explanation in c programming language.



(1)
What will be output of c code?



#include

int main() {

struct employee {

unsigned id: 8;

unsigned sex:1;

unsigned age:7;

}; struct employee emp1={203,1,23};



printf("%d\t%d\t%d",emp1.id,emp1.sex,emp1.age);




return 0;

}





Output:

Tuesday, January 24, 2012