C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Example of union

Posted By: Bin Fischer     Category: C Programming     Views: 17143

Program that illustrates an example of union.

Code for Example of union in C Programming

union marks        \\ A
    float perc;    \\ B
    char grade;    \\ C
main ( )
    union marks student1;    \\ E
    student1.perc = 98.5;    \\ F
    printf( “Marks are %f   address is  %16lu\n”, student1.perc, &student1.perc);  \\ G 
    student1.grade = ‘A’’;    \\ H    
    printf( “Grade is  %c  address is  %16lu\n”, student1.grade, &student1.grade);    \\ I

Didn't find what you were looking for? Find more on Example of union Or get search suggestion and latest updates.

Bin Fischer
Bin Fischer author of Example of union is from Frankfurt, Germany.
View All Articles

Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

No Comment Found, Be the First to post comment!