Friday 4 January 2019

Filled Under:

Electricity Bill[c programming examples with output]

C programming examples with output

Electricity Bill
Program

#include<stdio.h>
#include<conio.h>
main()
{
        int cno,pmr,cmr,cu;
        float total;
        char sec;
        char cname[10];
        clrscr();
        printf("Enter the sector                :");
        scanf("%c",&sec);
        printf("Enter customer name        :");
        scanf("%s",cname);
        printf("Enter customer number     :");
        scanf("%d",&cno);
        printf("Enter the previous units     :");
        scanf("%d",&pmr);
        printf("Enter the current units       :");
        scanf("%d",&cmr);
        cu=cmr-pmr;
        if(sec=='a')
          {
            if(cu>300)
            total=cu*2.00;
                 if(cu>200 && cu<=300)
                 total=cu*1.50;
                       if(cu>100 && cu<=200)
                       total=cu*1.00;
                             if(cu<=100)
                             total=cu*0.50;
          }
          if(sec=='i')
          {
              if(cu>300)
              total=cu*4.00;
                     if(cu>200 && cu<=300)
                     total=cu*3.00;
                             if(cu>100 && cu<=200)
                             total=cu*2.00;
                                      if(cu<=100)
                                      total=cu*1.00;
}
if(sec=='d')
   {
          if(cu>300)
          total=cu*2.00;
                  if(cu>200 && cu<=300)
                  total=cu*1.50;
                         if(cu>100 && cu<=200)
                         total=cu*1.00;
                                if(cu<=100)
                                total=cu*0.50;
  }
           printf("\nCustomer name     :  %s",cname);
           printf('\nCustomer number   :  %d",cno);
           prinf("\nPrevious units         :  %d",pmr);
           printf('\nCurrent units           :  %d",cmr);
           printf("\nCategory                 :  %c",sec);
           printf("\nConsumed units      :  %d",cu);
           printf("\nElectric bill             :  %f",total);
           getch();
}

Output
Enter the sector                 :i
Enter customer name        :Ram
Enter customer number    :1234
Enter the privious units     :567
Enter the current units       :890
Customer name                 :Ram
Customer number             :1234
Previous units                   :567
Current units                     :890
Category                           :i
Consumed units                :323

0 komentar:

Post a Comment