Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
C language program
1. C Language Program
Write a C program to input electricity unit charge and calculate the total electricity bill according to
the given condition:
For first 50 units Rs. 0.50/unit
For next 100 units Rs. 0.75/unit
For next 100 units Rs. 1.20/unit
For unit above 250 Rs. 1.50/unit
An additional surcharge of 20% is added to the bill.
How to calculate electricity bill using if else in C programming. Program to find electricity bill using if
else in C. Logic to find net electricity bill in C program.
/**
* C program to calculate total electricitybill
*/
#include <stdio.h>
int main()
{
int unit;
floatamt, total_amt,sur_charge;
/*
* Read unitconsumedfromuser
*/
printf("Entertotal unitsconsumed:");
scanf("%d",&unit);
/*
* Calculate electricitybillaccordingtogivenconditions
*/
if(unit<= 50)
{
amt = unit* 0.50;
}
else if(unit<= 150)
{
amt = 25 + ((unit-50)*0.75);
}
else if(unit<= 250)
{
amt = 100 + ((unit-150)*1.20);
}
else
{
amt = 220 + ((unit-250)*1.50);
}
/*
* Calculate total electricitybill
* afteraddingsurcharge
*/
sur_charge = amt * 0.20;
total_amt = amt + sur_charge;
printf("ElectricityBill =Rs. %.2f",total_amt);
return0;
2. }
to display the larger one out of the three given
unequal numbers
#include <stdio.h>
intmain()
{
double n1,n2, n3;
printf("Enterthree numbers:");
scanf("%lf %lf %lf",&n1, &n2, &n3);
if( n1>=n2 && n1>=n3 )
printf("%.2f isthe largestnumber.",n1);
if( n2>=n1 && n2>=n3 )
printf("%.2f isthe largestnumber.",n2);
if( n3>=n1 && n3>=n2 )
printf("%.2f isthe largestnumber.",n3);
return0;
}
4. Program to calculate simple interest
/*
* C program to calculate simple interest
*/
#include <stdio.h>
int main() {
float principle, rate, time, simpleInterest;
/*
* Take Principle, Rate of interest and
* Time as input from user.
*/
printf("Enter Principle Amountn");
scanf("%f", &principle);
printf("Enter Rate of Interestn");
scanf("%f", &rate);
printf("Enter Time of Loann");
scanf("%f", &time);
/*
* Simple Interest = (Principle X Rate X Time)/100;
*/
simpleInterest = (principle * rate * time)/100;
printf("Simple Interest = %.2f", simpleInterest);
return 0;
}
5. to determine whether a given number is prime number or not
#include <stdio.h>
intmain()
{
int n,i, flag= 0;
printf("Enterapositive integer:");
scanf("%d",&n);
for(i=2;i<=n/2; ++i)
{
//conditionfornonprime number
if(n%i==0)
{
flag=1;
break;
}
}
if (flag==0)
printf("%disaprime number.",n);
else
printf("%disnotaprime number.",n);
return0;
}