Advertisement
/* An example of structure with array element */
#include<stdio.h>
int main()
{
/* Declaring a structure */
struct employee
{
char name[20];
int age;
float salary;
};
/* Declaring a structure variable */
struct employee e1;
printf("Enter the name of employee : ");
gets(e1.name); /* using gets() function to read a multi-word string from console */
printf("Enter the age of employee :");
scanf("%d", &e1.age);
printf("Enter the salary of the first employee : ");
scanf("%f", &e1.salary);
printf("The name of first employee : %s", e1.name);
printf("\n");
printf("The age of first employee : %d", e1.age);
printf("\n");
printf("The salary of first employee : %.2f", e1.salary);
return 0;
}
Enter the name of employee : First Employee
Enter the age of employee :24
Enter the salary of the first employee : 10000
The name of first employee : First Employee
The age of first employee : 24
The salary of first employee : 10000.00
Advertisement
struct employee
{
char name[20];
int age;
float salary;
};
struct employee e1;
printf("Enter the age of employee :");
scanf("%d", &e1.age);
printf("The salary of employee is : : %.2f", e1.salary);
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement