C Language - Unions
#include <stdio.h>
#include <string.h>
union emp
{
int id;
char name[22];
int phoneNo;
};
union emp ahmad;
int main()
{
ahmad.id = 2435;
ahmad.phoneNo = 0343;
strcpy (ahmad.name, "The name of employee is Ahmad\n");
printf ("The id of employee is %d\n", ahmad.id);
printf ("The phone number of employee is %d\n", ahmad.phoneNo);
printf (" %s\n", ahmad.name);
return 0;
}
// ScreenShots:
Comments
Post a Comment