-->

Write a C program to define a structure which contains ename, eno and esalary and prints the same on the screen.

introduction to structures
Write a C program to define a structure which contains ename, eno and esalary and prints the same on the screen.
#include<stdio.h>
#include<conio.h>
// New structure by name employee is defined
struct employee
{
char ename[20];
int eno;
float esalary;
};
vow main()
{
struct employee e1; // Declaring a variable el of type 'employee'
printf("\ri Input values \n");
//Reading values into individual elements of e1
scanf("%s %d %f', &e1.ename ,&e1.eno ,&e1.esalary
// Printing individual elements of el
printf("%s %d %f', e1.ename,e1.eno,e1.esalary);
}






Every variable of 'employee' type now will have three elements namely, ename, eno, salary







e1.ename Refers to ename element of e1 and is a character array
e1.eno Refers to e1's esalary element which is a floating point number
e1.esalary Refers to eno of e1 which is an int

OUTPUT:
Input values
RAMU   10           10000
RAMU   10           10000

Related Posts

Subscribe Our Newsletter