Thursday, October 29, 2020

C program of electricity bill

 #include <stdio.h>

int main() {

    int u;

    printf("Enter units consumed:");

    scanf("%d",&u);

    if(u<=100)

        printf("Net Bill=%d",u);

    else if(u<=200)

        printf("Net Bill=%d",100+(u-100)*1);

    else if(u<=300)

        printf("Net Bill=%d",250+(u-200)*2);

    else if(u<=400)

        printf("Net Bill=%d",500+(u-300)*3);

    else

        printf("Net Bill=%d",750+(u-400)*5);

}

No comments:

Post a Comment

How to Fight Overthinking or Negative Thoughts?

How to Combat Overthinking or Negative Thoughts? 1. Don’t Fight Your Thoughts Trying to suppress or control negative thoughts often backfire...