Skip to main content

Write a C program to calculate the amount to be paid by a customer for electricity bill.



5
Write a C program to calculate the amount to be paid by a customer for electricity bill.
Where Unit Consumed = Current meter reading – Past meter reading and
            Total Bill = Unit Consumed * Charge per unit
Input: customer number, customer name, past reading (in units), present reading (in units), charge per unit
Output: (Print with same format shown here)
                  Electricity Bill
---------------------------------------------------------
Customer Number             : *****
Customer Name                : **********************
Past Reading                     : ********
Current Reading                : ********
Units Consumed                : ********
Charge Per Unit                 : **.**
Amount to be paid (Rs.)     : ******.**
----------------------------------------------------------

#include<stdio.h>
#include<conio.h>
void main()
{
int cusno,total,start,stop,reading,charge;
char cusname[20];
clrscr();
printf("Enter The Customer No=");
scanf("%d",&cusno);
flushall();
printf("Enter The Customer Name=");
scanf("%[^\n]",cusname);
printf("Enter The Starting And Ending Reading=");
scanf("%d%d",&start,&stop);
printf("Enter The Charge Of Unit=");
scanf("%d",&charge);
reading=stop-start;
total=reading*charge;
printf("\n\n\n\t\tThe Customer No Is=%d",cusno);
printf("\n\t\tThe Customer Name Is=%s",cusname);
printf("\n\t\tThe Starting Reading Is=%d",start);
printf("\n\t\tThe Ending Reading Is=%d",stop);
printf("\n\t\tThe Total Reading Is=%d",reading);
printf("\n\t\tThe Total Bill You Have To Pay Is=%d",total);

getch();
}







Comments

Popular posts from this blog

Learn C Programming

Learn C Programming      The Definitive Guide C is a powerful general-purpose programming language. It is fast, portable and available in all platforms. If you are new to programming, C is a good choice to start your programming journey. This is a comprehensive guide on how to get started in C programming language, why you should learn it and how you can learn it. What is C (Programming Language)? - The Basics Before getting started with C programming, lets get familiarized with the language first. C is a general-purpose programming language used for wide range of applications from Operating systems like Windows and iOS to software that is used for creating 3D movies. C programming is highly efficient. That’s the main reason why it’s very popular despite being more than 40 years old. Standard C programs are portable. The source code written in one system works in another operating system without any change. As mentioned,

To find minimum and maximum number from given three numbers.

3. To find minimum and maximum number from given three numbers. #include<stdio.h> #include<conio.h> void main() { int a,b,c; clrscr(); printf("Enter The Value Of A,B,C="); scanf("%d%d%d",&a,&b,&c);         if((a>b)&&(a>c))                 printf("The Greater Number Is A=%d",a);         else if((b>c)&&(b>a))                 printf("The Greater Number Is B=%d",b);         else                 printf("The Greater Number Is C=%d",c);         getch(); }

C – Language History

The C programming language is a structure oriented programming language, developed at Bell Laboratories in 1972 by Dennis Ritchie C programming language features were derived from an earlier language called “B” (Basic Combined Programming Language – BCPL) C language was invented for implementing UNIX operating system In 1978, Dennis Ritchie and Brian Kernighan published the first edition “The C Programming Language” and commonly known as K&R C In 1983, the American National Standards Institute (ANSI) established a committee to provide a modern, comprehensive definition of C. The resulting definition, the ANSI standard, or “ANSI C”, was completed late 1988. C programming language standards: C89/C90 standard – First standardized specification for C language was developed by the American National Standards Institute in 1989. C89 and C90 standards refer to the same programming language. C99