A very simple employees record using union that I wrote using C language. I wrote this code while writing my book entitled "Introduction to C Programming". I hope you will find my work useful. Thank you.
I am currently accepting programming work, it projects, school
programming projects, thesis and capstone projects, IT consulting
work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
include <stdio.h>
#include <string.h>
union Employee
{
int age;
char Name[100];
char Department[100];
float Salary;
};
int main()
{
union Employee emp1;
union Employee emp2;
emp1.age = 28;
strcpy(emp1.Name, "Julianna Rae Pomperada");
strcpy(emp1.Department, "Computer Science");
emp1.Salary = 32000.70;
printf("\n\n");
printf("\tDetails of the First Employee \n");
printf("\tEmployee Age = %d \n", emp1.age);
printf("\tEmployee Name = %s \n", emp1.Name);
printf("\tEmployee Department = %s \n", emp1.Department);
printf("\tEmployee Salary = %.2f \n\n", emp1.Salary);
printf("\tDetails of the Second Employee \n" );
emp2.age = 30;
printf("\tEmployee Age = %d \n", emp2.age );
strcpy(emp2.Name, "Julianna Rae Pomperada");
printf("\tEmployee Name = %s \n", emp2.Name );
strcpy(emp2.Department, "Information Technology" );
printf("\tEmployee Department = %s \n ", emp2.Department );
emp2.Salary = 35000.20;
printf("\tEmployee Salary = %.2f \n ", emp2.Salary );
printf("\n\n");
printf("\t\tEnd of Program");
printf("\n\n");
system("pause");
}
I am currently accepting programming work, it projects, school
programming projects, thesis and capstone projects, IT consulting
work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
My personal website is http://www.jakerpomperada.com
My personal website is http://www.jakerpomperada.com
Program Listing
#include <string.h>
union Employee
{
int age;
char Name[100];
char Department[100];
float Salary;
};
int main()
{
union Employee emp1;
union Employee emp2;
emp1.age = 28;
strcpy(emp1.Name, "Julianna Rae Pomperada");
strcpy(emp1.Department, "Computer Science");
emp1.Salary = 32000.70;
printf("\n\n");
printf("\tDetails of the First Employee \n");
printf("\tEmployee Age = %d \n", emp1.age);
printf("\tEmployee Name = %s \n", emp1.Name);
printf("\tEmployee Department = %s \n", emp1.Department);
printf("\tEmployee Salary = %.2f \n\n", emp1.Salary);
printf("\tDetails of the Second Employee \n" );
emp2.age = 30;
printf("\tEmployee Age = %d \n", emp2.age );
strcpy(emp2.Name, "Julianna Rae Pomperada");
printf("\tEmployee Name = %s \n", emp2.Name );
strcpy(emp2.Department, "Information Technology" );
printf("\tEmployee Department = %s \n ", emp2.Department );
emp2.Salary = 35000.20;
printf("\tEmployee Salary = %.2f \n ", emp2.Salary );
printf("\n\n");
printf("\t\tEnd of Program");
printf("\n\n");
system("pause");
}
No comments:
Post a Comment