Program To Create EB Bill Using Structures
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