Here is a sample program that I wrote using Union in C to display the employee's profile. The code is very simple which I learned during the time I'm writing my book on C programming. I hope you will find my work useful in your quest in learning C programming.
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<stdio.h>
union emp
{
char emp_name[100];
char emp_position[100];
int age;
float salary;
};
void main()
{
union emp profile;
printf("\n\n");
printf("\tEmployee's Profile Using Union");
printf("\n\n");
printf("\tEmployees Name : ");
gets(profile.emp_name);
printf("\n");
printf("\tName : %s\n",profile.emp_name);
printf("\n");
printf("\tEmployees Position : ");
gets(profile.emp_position);
printf("\n");
printf("\tYour position is %s.\n",profile.emp_position);
printf("\n");
printf("\tEmployees Age : ");
scanf("%d",&profile.age);
printf("\n");
printf("\tYour age is %d year(s) old.\n",profile.age);
printf("\n");
printf("\tEmployees Salary : PHP ");
scanf("%f",&profile.salary);
printf("\n");
printf("\tYour salary is PHP %.2f",profile.salary);
printf("\n\n");
printf("\tEnd of Program");
printf("\n\n");
}
No comments:
Post a Comment