Declare the structure EB, consisting of member variables are cust_id, st_reading, end_reading and tot_usage. Calculate the usage of electric energy and display the details of electricity bill of a customer.
Runtime Input :
150
2100
2200
100
Output :
150
2100
2200
100
#include <stdio.h>
#define NO_OF_CUSTOMERS 1
struct EB
{
int cust_ID;
int st_reading;
int end_reading;
int tot_usage;
};
main(void)
{
struct EB Cust[NO_OF_CUSTOMERS];
int n;
for(n=0;n<NO_OF_CUSTOMERS;n++)
{
printf("\nEnter Customer ID : "); scanf("%d",&Cust[n].cust_ID);
printf("\nEnter Start Reading: "); scanf("%d",&Cust[n].st_reading);
printf("\nEnter End Reading: "); scanf("%d",&Cust[n].end_reading);
Cust[n].tot_usage = Cust[n].end_reading-Cust[n].st_reading;
}
for(n=0;n<NO_OF_CUSTOMERS;n++)
{
printf("\nEnter Customer ID : %d",Cust[n].cust_ID);
printf("\nEnter Start Reading: %d",Cust[n].st_reading);
printf("\nEnter End Reading: %d",Cust[n].end_reading);
printf("\nTotal Usage : %d",Cust[n].tot_usage);
}
return(0);
}
Comments
Leave a comment