- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Environmental Science
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to reads customer number and power consumed and prints amount to be paid using C
An electric power distribution company charges its domestic consumers as follows
Consumption Rate of Units Charge
------------------------------------
0-200 Rs.0.50 per unit
201-400 Rs.100 plus Rs.0.65 per
unit excess 200
401-600 Rs.230 plus Rs.0.80 per
unit excess of 400.
------------------------------------
Write a C program that reads the customer number and power consumed and prints the amount to be paid by the customer.
Program :
#include <stdio.h>
#include <conio.h>
void main() {
int cust_no, powerUsage;
float amount;
clrscr();
printf("Enter the customer number: ");
scanf("%d", &cust_no);
printf("Enter the power consumed: ");
scanf("%d", &powerUsage);
if (powerUsage >= 0 && powerUsage <= 200) amount = powerUsage * 0.50; else if (powerUsage > 200 && powerUsage < 400) amount = 100 + ((powerUsage - 200) * 0.65); else if (powerUsage > 400 && powerUsage <= 600)
amount = 230 + ((powerUsage - 400) * 0.80);
printf("Amount to be paid by customer no. %d is Rs.:%5.2f.", cust_no, amount);
getch();
}
Output :
Enter the customer number: 1
Enter the power consumed: 100
Amount to be paid by customer no. 1 is Rs.:50.00.
- Related Questions & Answers
- Write C Program to Delete duplicate elements from an array
- How to make a chain of function decorators in Python?
- Write C Program to Find Factorial of Number Using Recursion
- How can we create recursive functions in Python?
- How to Calculate Area of Right angle Triangle using C Language
- Write a ‘C’ Program to compute the sum of all elements stored in an array using pointers
- How to reverse a given number using C
- How to read the values of x, y and z and print the results expressions in one line using C Program
- How to print hello world using C Language
- How To Clean Up Unnecessary Code From WordPress Header Without Plugins
- Write a C program using pointers to read in an array of integers and print its elements in reverse order.
- How to find sum of two numbers using C Language
- Write C Program to Find Largest Element in Array in C Programming
- How To Reduce the Array to 0 by decreasing elements by 1 or replacing at most K elements by 0
- How to get a list of parameter names inside Python function?
- How to convert temperature from degree centigrade to Fahrenheit using C
Advertisements
ads