Answer to Question #217503 in C for Mohammed Ashiq

Question #217503
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-16T01:04:42-0400
#include <stdio.h>
#include <stdlib.h>


struct Mark {
    unsigned int Pass : 1;    
    unsigned int A : 4;
    unsigned int B : 5;
    unsigned int C : 6;
};


int main(int argc, char* argv[]) 
{
    struct Mark m = { 0 };
    m.Pass = 1;    
    m.B = 1;    


    if (m.Pass)
    {
        printf("Pass\n");
        if (m.A)
            printf("A\n");
        if (m.B)
            printf("B\n");
        if (m.C)
            printf("C\n");
    }
    else
    {
        printf("Fail\n");
    }
    


    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