In: Computer Science
Use c programing. Declare a new employee struct. Prompt the user to enter values for two-member data of the struct. Store struct data in employee struct. Use the calculate(raise_function) to increase employee salary and store the result in employee structure. Use print_ structure to print employee structure.
Program :
#include <stdio.h>
void print_structure();
void raise_function();
struct employee
{
char name[25];
int salary;
}e[2];
int main()
{
int i;
for(i = 0; i < 2; i++)
{
printf("\nEnter %dst Employee record:\n", i+1);
printf("\nEmployee name:\t");
scanf("%s", e[i].name);
printf("\nEnter Salary:\t");
scanf("%d", &e[i].salary);
}
raise_function();
print_structure();
return 0;
}
void raise_function()
{
int n;
printf("Enter first employee salary to increase:");
scanf("%d",&n);
e[0].salary=e[0].salary+n;
printf("Enter second employee salary to increase:");
scanf("%d",&n);
e[1].salary=e[1].salary+n;
}
void print_structure()
{
int i;
printf("\nDisplaying Employee record after increasing:\n");
for(i = 0; i < 2; i++)
{
printf("\nEmployee name is %s", e[i].name);
printf("\nSalary is %d", e[i].salary);
}
}
Screenshot of the program:
Output :