In this tutorial you will learn about the C Program to Calculate Telephone Call Bills and its application with practical example.
C Program to Calculate Telephone Call Bills
In this tutorial, we will learn to create a C program that will Calculate Telephone Call Bills using C programming.
Prerequisites
Before starting with this tutorial we assume that you are best aware of the following C programming topics:
- Operators in C Programming.
- Basic Input and Output function in C Programming.
- Basic C programming.
- While loop in C programming.
- Arithmetic operations in C Programming.
Program to Calculate Telephone Call Bills
In c programming, it is possible to take numerical input from the user and calculate Telephone Call Bills with the help of a very small amount of code. The C language has many types of header libraries which has supported function in them with the help of these files the programming is easy. But today we will Calculate Telephone Call Bills using c programming. As per the following rule:
Minimum Rs. 200 for up to 100 calls.
Plus Rs. 0.60 per call for the next 50 calls.
Plus Rs. 0.50 per call for the next 50 calls.
Plus Rs. 0.40 per call for any call beyond 200 calls.
With the help of this program, we can Calculate Telephone Call Bills.
Algorithm:-
1 2 3 4 5 6 7 8 9 10 11 |
1. Declaring the variables for the program. 2. Taking the input minutes in number from the user. 3. Checking the minutes used. 4. Checking the plans. 5. Printing the result numbers. 6. End the program. |
Program to Calculate Telephone Call Bills:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
#include <stdio.h> int main() { //declaring the variable for the program int calls; float bill; //showing the message for the input printf("Enter number of calls :"); //scanning the minutes number scanf("%d", &calls); //cheking the minutes with the plans if (calls <= 100) { bill = 200; } else if (calls > 100 && calls <= 150) { calls = calls - 100; bill = 200+(0.60 *calls); } else if (calls > 150 && calls <= 200) { calls = calls - 150; bill = 200+(0.60 *50) + (0.50 *calls); } else { calls = calls - 200; bill = 200 + (0.60 * 50) + (0.50 * 50) + (0.40 * calls); } //printing the calculated bill for the callings printf("Your bill is Rs. %0.2f", bill); return 0; } |
Output:-
In the above program, we have first initialized the required variable.
- calls = it will hold the integer value for the calls in minutes.
- bill = it will hold the floating value for the bills.
Input number from the user.
Program Logic Code.
Printing output for bill generated.