0% found this document useful (0 votes)
72 views

Program To Create EB Bill Using Structures

The document defines a C program to create an electricity bill using structures. It defines a structure called 'eb' with fields to store customer name, electricity number, previous reading, current reading, units consumed, and amount. It takes input for two customers, calculates units as difference of current and previous reading, calculates amount based on slab rates, and prints the bill with customer details and calculations.

Uploaded by

kalanithi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views

Program To Create EB Bill Using Structures

The document defines a C program to create an electricity bill using structures. It defines a structure called 'eb' with fields to store customer name, electricity number, previous reading, current reading, units consumed, and amount. It takes input for two customers, calculates units as difference of current and previous reading, calculates amount based on slab rates, and prints the bill with customer details and calculations.

Uploaded by

kalanithi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Program to create EB Bill using structures

#include
#include
struct eb
{
char n[10][10];
int en[10],pr[10],cr[10],u[10];
float am[10];
};
struct eb e;
void main()
{
int i;
clrscr();
for(i=0;i<2;i++)
{
printf("\nDATA=%d\n",i+1);
printf("Enter the name:");
scanf("%s",e.n[i]);
printf("Enter the EB-number:");
scanf("%d",&e.en[i]);
printf("Enter the previous reading:");
scanf("%d",&e.pr[i]);
printf("Enter the current reading:");
scanf("%d",&e.cr[i]);
}
printf("NAME\tEB.NO\tPREVIOUS READING\tCURRENT READING\tUNIT\tAMOUNT\n");
for(i=0;i<2;i++)
{
e.u[i]=e.cr[i]-e.pr[i];
if(e.u[i]<=100)
e.am[i]=e.u[i]*1.00;
else
if(e.u[i]>100&&e.u[i]<=200)
e.am[i]=e.u[i]*2.00;
else

if(e.u[i]>200)
e.am[i]=e.u[i]*3.00;
printf("%s\t%d\t%d\t%d\t%d\t%f\n",e.n[i],e.en[i],e.pr[i],e.cr[i],e.u[i],e.am[i]);
}
getch();
}

OUTPUT:
DATA:1
Enter
Enter
Enter
Enter

the
the
the
the

name:Ganesh
eb-number:7900
previous reading:900
current reading:1000

DATA:2
Enter
Enter
Enter
Enter

the
the
the
the

name:Sasi
eb-number:7901
previous reading:200
current reading:500

NAME ,EB-NO ,PREVIOUS-READING, CURRENT-READING, UNIT, AMOUNT


Ganesh ,7900 , 900 , 1000, 100 , 100.00
Sasi ,7901 , 200 , 500 , 300 , 900.00

You might also like