Telephone Bill

Given the number of calls of a user the task is to calculate total bill based on given tariff.

  • From 1 to 50 calls 3 ₹/call
  • From 51 to 150 calls 2.5 ₹/call
  • From 151 to 350 calls 2 ₹/call
  • From 351 to 750 calls 1.5 ₹/call
  • More than 750 calls 1 ₹/call
C
#include <stdio.h>
int main()
{
    int n=0;
    double amt=0.0;
    printf("Number Of Calls: ");
    scanf("%d",&n);
    if(n>0&&n<=50)
    {
        amt=n*3;
    }
    else if(n>50&&n<=150)
    {
        amt=n*2.5;
    }
    else if(n>150&&n<=350)
    {
        amt=n*2;
    }
    else if(n>350&&n<=750)
    {
        amt=n*1.5;
    }
    else if(n>750)
    {
        amt=n*1;
    }
    else
    {
        printf("Number of calls can't be non-zero or negative");
    }
    printf("Payable Amount: Rs %lf",amt);
    return 0;
}
C