program using structure to take user input and display it and we can also access the user by its id

program using structure to take user input and display it and we can also access the user by its id
#include<stdio.h>
#include<string.h>
struct emply
{
    char name[50];
    int user_id;
    int salaray;
}emp1[100];
int main()
{
    int id=0,j,i,k =1,h =1,m,l;
    char str1[100];
    printf("How many users data u need to store\n");
    scanf("%d",&l);
    for ( m = 0; m < l; m++)
    {
        printf("\nName : \n");
        scanf("%s",&emp1[m].name);
        //strcpy(emp1[m].name,str1);
        printf("Enter User_id : ");
        scanf("%d",&emp1[m].user_id);
        emp1[m].salaray = 100000;
    }
    printf("\t-------------------------------------------------------------------------\n");
    printf("\t|sl.no\t|Employee name |\tEmployee ID\t|\tEmployee Salary |\n");
    printf("\t|-------|--------------------|------------------|-----------------------|\n");
    for(i=0;i<l;i++)
    {
        printf("\t|%d\t|%-20s|\t\t%d\t|\t\t%ld |\n",i+1,emp1[i].name,emp1[i].user_id,emp1[i].salaray);
        printf("\t|-------|--------------------|------------------|-----------------------|\n");
    }
    printf("\t-------------------------------------------------------------------------\n\n");
    printf("Enter your user id to access your account\n");
    scanf("%d",&id);
    for (j = 0; j < l; j++)
    {
        if (emp1[j].user_id == id)
        {
            --h;
            printf("Name : %s\n",emp1[j].name);
            printf("User_id : %d\n",emp1[j].user_id);
            printf("Salary : %d\n\n",emp1[j].salaray);
        }
    }
    if (k == h)
    {
        printf("No user found\n");
    }
     return 0;
}
Posted on by