A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

C program to read and print an employee\'s detail using structure
Q:

C program to read and print an employee\'s detail using structure

0

C program to read and print an employee's detail using structure

C program to read and print an Employee’s Details using Structure - In this program, we will read employee’s details like name, employee id and salary using structure and then print the entered values.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Employee Detail program in C

/*C program to read and print employee's record using structure*/
 
#include <stdio.h>
 
/*structure declaration*/
struct employee{
    char    name[30];
    int     empId;
    float   salary;
};
 
int main()
{
    /*declare structure variable*/
    struct employee emp;
     
    /*read employee details*/
    printf("\nEnter details :\n");
    printf("Name ?:");          gets(emp.name);
    printf("ID ?:");            scanf("%d",&emp.empId);
    printf("Salary ?:");        scanf("%f",&emp.salary);
     
    /*print employee details*/
    printf("\nEntered detail is:");
    printf("Name: %s"   ,emp.name);
    printf("Id: %d"     ,emp.empId);
    printf("Salary: %f\n",emp.salary);
    return 0;
}

Output

Enter details :
Name ?:Mike
ID ?:1120
Salary ?:76543

Entered detail is:
Name: Mike
Id: 1120
Salary: 76543.000000

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now