Skip to main content

Electricity Bill

Electricity Bill program

#include <stdio.h>

void main()

{

    int units;

    float charges;

    char name[20];

    printf("Enter the name of the customer\n");

    scanf("%s",name);

    printf("Enter the units consumed\n");

    scanf("%d",&units);

    charges=100;

    if(units>0&&units<=200)

    charges=charges+0.8*units;

    else if (units>200&&units<=300)

    charges=charges+0.8*200+(300-units)*0.9;

    else

    charges=charges+0.8*200+100*0.9+(units-300)*1;

    if(charges>400)

    charges=charges+0.15*charges;

    printf("name=%s\n",name);

    printf("units consumed=%d\n",units);

    printf("charges=%f\n",charges);

}

Algorithm

Start

Read name, units consumed as units

charge = 100

if units is <= 100 then 

compute charge = charge + units * 0.8 

else If units > 200 and units < 300 then 

compute charge = charge + 200 * 0.8 +(units – 200) * 0.9 

else 

compute charge = charge + (0.15*charge) 

Display name, units, charge

Stop


Comments

Popular posts from this blog

Raju is a Civil Engineer. He is writing software to automate his work. As a part of his requirement, he wants to calculate the circle diameter, circumference, and area. Help Raju to complete his task. Get radius as input.

OUTPUT

Implement structures to read, write and compute average- marks and the students scoring above and below the average marks for a class of N students Program and Algorithm Computer Science Engineering VTU

Structures abov below avg #include<stdio.h> struct student { char name [100]; char usn [20]; float marks; }; void main() { int i,j,k,m,n,aboveavg[100],belowavg[100]; float total=0.0,avg=0.0; struct student s[100]; printf("enter number of students\n"); scanf("%d",&n); for(i=0;i<n;i++) { printf("enter the details of students%d\n",i+1); printf("enter name\n"); scanf("%s",s[i].name); printf("enter usn\n"); scanf("%s",s[i].usn); printf("enter marks\n"); scanf("%f",&s[i].marks); total+=s[i].marks; } printf("enter the details of students\n"); printf("name\t\t usn\t\t marks\n"); for(i=0;i<n;i++) printf("%s\t\t %s\t\t %f\n",s[i].name,s[i].usn,s[i].marks); avg=total/n; printf("avg=%f\n",avg); j=0; k=0; for(i=0;i<n;i++) { if(s[i].marks>avg) abov...