Answer to Question #217504 in C for Mohammed Ashiq

Question #217504
Write a C program to display the examination result of students using bit fields. * The student information are Pass=1, Fail=0, A=4, B=5, C=6 * The bit fields member variables are result and grade, the *name is of character type
1
Expert's answer
2021-07-15T07:11:35-0400
#include <stdio.h>
#define  Pass  1
#define  Fail  0
#define  A  4
#define  B  5
#define  C  6


struct student  {
	// The bit fields member variables are result and grade, the *name is of character type
    char* name;
    unsigned result: 1;
    unsigned grade : 4;
};
 
int main(){
 
    struct student newStudent = { "Mary", Pass, B};


	printf("Name: %s\n", newStudent.name);
	printf("Result: %d\n", newStudent.result);
	printf("Grade: %d\n", newStudent.grade);


	getchar();
	getchar();
	return 0;
}




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS