Answer to Question #213313 in C for Prasanna

Question #213313

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


1
Expert's answer
2021-07-05T01:08:10-0400
#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);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS