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

C – Data Types

C data types are defined as the data storage format that a variable can store a data to perform a specific operation. Data types are used to define a variable before to use in a program. Size of variable, constant and array are determined by data types. C – data types: There are four data types in C language. They are, Types Data Types Basic data types int, char, float, double Enumeration data type enum Derived data type pointer, array, structure, union Void data type void 1. Basic data types in C language: 1.1. Integer data type: Integer data type allows a variable to store numeric values. “int” keyword is used to refer integer data type. The storage size of int data type is 2 or 4 or 8 byte. It varies depend upon the processor in the CPU that we use.  If we are using 16 bit processor, 2 byte  (16 bit) of memory will be allocated for int dat...

Write a program to do the following operations:

6. Write a program to do the following operations: --Read any two positive integer operands (say op1 & op2) and one character                type operator (say opr). Note that opr is any mathematical operator. --Depending upon the operator, do the appropriate operation. e.g. if opr is '+'                 then the display the value obtained by evaluating the expression (op1 + op2) #include<stdio.h> #include<conio.h> void main() {         int a,b;         char n;         clrscr(); printf(“enter the value of a and b=”);         scanf(“%d%d”,&a,&b);         printf(“enter the operation to perform=”); ...

C – Programming Basics

If you are looking for C programs, please click here “C programs”. This C programming basics section explains a simple “Hello World” C program. Also, it covers below basic topics as well, which are to be known by any C programmer before writing a C program. C programming basic commands to write a C program A simple C program with output and explanation Steps to write C programs and get the output Creation, Compilation and Execution of a C program * How to install C compiler and IDE tool to run C programming codes Basic structure of a C program * Example C program to compare all the sections * Description for each section of the C program C programs ( Click here for more C programs )  with definition and output – C program for Prime number, Factorial, Fibonacci series, Palindrome, Swapping 2 numbers with and without temp variable, sample calculator program and sam...