Program using structure to store information of 2 employees (emp_id, name,salary) and display the details of the employee having salary greater

              


Code: 

#include <stdio.h>
struct employee
{
    char name[20];
    int  id;
    float salary;
};
int main() {
struct employee e[10];
int i;
printf("Details of Employee\n");
for(i=0;i<2;i++)
{
    printf("Enter the employee Name:");
    scanf("%s",e[i].name);
    printf("Enter the employee Id:");
    scanf("%d",&e[i].id);
    printf("Enter the employee Salary:");
    scanf("%f",&e[i].salary);
    
}
   
 printf("Details of Employee whose salary is greater:");
 if(e[0].salary<e[1].salary)
 {
     printf("\nEmployee name:%s\nEmployee Id:%d\nEmployee Salary:%f",e[1].name,e[1].id,e[1].salary);
 }
 else 
 {
    printf("\nEmployee name:%s\nEmployee Id:%d\nEmployee Salary:%f",e[0].name,e[0].id,e[0].salary);
 
    
}

return 0;
}

Sample Input and Output:

Details of Employee
Enter the employee Name:Pankaj
Enter the employee Id:12
Enter the employee Salary:84842
Enter the employee Name:Siddhiraj
Enter the employee Id:13
Enter the employee Salary:94949
Details of Employee whose salary is greater:
Employee name:Siddhiraj
Employee Id:13
Employee Salary:94949.000000

 
If you any have doubt,suggestion regarding this post or website then feel free to share with us.
 
If you have learned something new from this post then share this post with your family and
friends.
 
Happy Learning :)😎   


 

Previous Next

Post a Comment

Previous Post Next Post