C program to read the customer number and power consumed and print amount to be paid

We can find the sum of elements stored in an array using pointers. For example: if the number of elements to be added are 4 and if we give the elements one by one as 4 5 6 3, then the sum of elements stored in the array will be 18. The below given C program will find the sum of all elements in array using pointers. Kindly check out the program to find the sum of all elements in array using pointers

Program to read customer number, power consumed and print the amount to be paid

#include<stdio.h>

int main() {

unsigned long int CustomerNo;

int PowerUsed;

float amount;

printf("Give Your Customer number : ");

scanf("%ld", &CustomerNo);

printf("

Enter the power consumed : ");

scanf("%d", &PowerUsed);

if (PowerUsed >= 0 && PowerUsed <= 150)

amount = PowerUsed * 0.50;

else

if (PowerUsed > 150 && PowerUsed < 350)

amount = 75 + ((PowerUsed - 150) * 0.80);

else

if (PowerUsed > 350 && PowerUsed <= 800)

amount = 235 + ((PowerUsed - 350) * 1.50);

printf("



The customer no. %ld has to pay amount in INR : %6.2f", CustomerNo, amount);

return(0);

} Sample Output: Give Your Customer number : 3452

Enter the power consumed : 150



The customer no. 3452 has to pay amount in INR : 75.00

Related Popular Posts: