
In this, we are going to store Information of Employees using for loop with help of C Programming Language.
Â
#include <stdio.h>
struct student
{
char first_name[50];
char last_name[50];
int employee_number;
float salary;
} s[100];
int main()
{
int x, i;
// x is the number of Employee
printf("Enter the number of Employee: ");
scanf("%d", &x);
// It will store the student's information
printf("\nEnter the Employee's informations:\n");
for (i = 0; i < x; i++)
{
s[i].employee_number = i + 1;
printf("\nInformation for Employee Number: %d\n", s[i].employee_number);
printf("Enter the first name: ");
scanf("%s", s[i].first_name);
printf("Enter the last name: ");
scanf("%s", s[i].last_name);
printf("Enter the salary: ");
scanf("%f", &s[i].salary);
}
// It will display the student's information
printf("\n\nDisplay the Employee's information:\n");
for (i = 0; i < x; i++)
{
printf("\nThe Employee Number: %d\n", i + 1);
printf("The First Name: ");
puts(s[i].first_name);
printf("The Last Name: ");
puts(s[i].last_name);
printf("The salary: %.1f", s[i].salary);
printf("\n");
}
return 0;
}
//........coded by JAIDEEP JAMBHALE
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP