Basic Programs
If Else based Programs
Loop Based Programs
Array Based Programs
String Programs
Function Programs
Pointers Programs
Structure & File Handling Programs
Data Structure Programs
If Else based Programs
C Program to calculate telephone bill based on phone calls
Program to calculate the telephone bill based on the following conditions :
1. (0-200) first 200 calls are free
2. (200-500) Calls between 200 to 500 will be charged 1 /Call.
3. (500+) In this case first 200 call free (200-500) 1re/call and (500+) will be 2/call
4. 200 is rental in the final bill
For Example :600 calls will be calculated as (200*0 + 300*1 +100*2 + 200 ) = 700 (total bill)
#include <stdio.h> #include <conio.h> void main() { int calls, bill=0; printf("Enter the number of calls"); scanf("%d",&calls);
if(calls<=200) // first if condition for free calls upto 200 bill=0; if(calls>200&& calls<=500) // if condtion for 200 calls free +1 re/call on rest calls bill=200*0+ (calls-200)*1; if(calls>500) bill=200*0+300*1+(calls-500)*2; // if calls 200 free+ (200-500)->1Re/Call (500+)->2Re/call bill=bill+200; // 200 rental is added. printf("the final bill =%d",bill); }
Output of the above program is as following.
You may find some interesting program in index list try those.
Video/ C Introduction
Watch video in full size