Monday, 24 September 2018

Program to calculate electricity bill of a user in different cases in C

#include <stdio.h>
#include <conio.h>
void main ()
{
char name[25];
int choice;
float cahrge1,charge2,charge3,charge4,charge5,unit1,unit2,unit3,unit4,unit5;
printf ("\n enter name of user:");
scanf ("%s", name);
printf ("\n you can perform following operation:");
printf ("\n 1. below 83.33:");
printf ("\n 2. above 83.34 to 100:");
printf ("\n 3. above 100 to 200:");
printf ("\n 4. above 200 to 300:");
printf ("\n 5. above 300:");
printf ("\n enter your choice:"):
scanf ("%d", &choice);
switch ( choice )
{
       case 1:
       printf ("\n enter value of units:");
       scanf ("%d", &unit1);
       printf ("\n Energy charge is 50:");
break;
       case 2:
       printf ("\n enter value of units:");
       scanf ("%d", &unit2);
       charge2= 0.6*unit2;
       printf ("\n Charge=%d",charge2);
break;
       case 3:
       printf ("\n enter value of units:");
       scanf ("%d", &unit3);
       charge3=( 0.8*(unit3-100)+60;
       printf ("\n Charge=%d",charge3);
break;
       case 4:
       printf ("\n enter value of units:");
       scanf ("%d", &unit4);
       charge4=( 0.9*(unit4-200)+140);
       printf ("\n Charge=%d",charge4);
break;
       case 5:
       printf ("\n enter value of units:");
       scanf ("%d", &unit5);
       charge5=( 0.9*(unit5-300)+230);
       charge5=charge5+0.15*(charge5);
       printf ("\n Charge=%d",charge5);
break;
default:
        printf ("\n Have a nice day:");
}
getch ();
}




8 comments:

  1. That's pretty cool. I bet it's useful for some.

    ReplyDelete
  2. Im not smart enough to understand this.

    ReplyDelete
  3. This is really helps to all of programmers

    ReplyDelete
  4. OMG my brother will be thrilled to learn this code!

    ReplyDelete
  5. Looking for the best generator? Consumer Reports has honest ratings and reviews on generatorsfrom the unbiased experts you can trust. Going Here

    ReplyDelete
  6. obviously like your web-site Post Thanks for Shearing. i Read your Blog every day.it very bothersome to tell the reality then again I’ll definitely come back again.Please write more about this topics.
    More

    ReplyDelete

Featured post

Program to find Volume of given box in java

class volume { public static void main (String args []) { int l=5,b=6,h=10; int volume; volume=l*b*h; System.out.println (" vol...