0% found this document useful (0 votes)
9 views5 pages

Priya As

Uploaded by

Priyanka rani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views5 pages

Priya As

Uploaded by

Priyanka rani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

ASSIGNMENT 4

QUES1. WRITE A C PROGRAM TO INPUT BASIC SALARY OF AN EMPLOYEE AND


CALCULATE ITS GROSS SALARY ACCORDING TO FOLLOWING:BASIC SALARY<=
10000: HRA =20%,DA=80%
BASIC SALARY <=20000:HRA =25%,DA=90%
BASIC SALARY>20000:HRA=30%,DA=95%
#include<stdio.h>

int main(){
float bs,gs,da,hra;

printf("enter basic salary\n");


scanf("%f",&bs);

if (bs<=10000)
{
hra=bs*20/100;
da=bs*80/100;
printf("salary is %f",bs);
}
else if (bs<=20000)
{
hra=bs*25/100;
da=bs*90/100;
printf("salary is %f",bs);
}
else if (bs>20000)
{
hra=bs*30/100;
da=bs*95/100;
printf("salary is %f",bs);
}

gs=bs+hra+da;
printf("gross salary is Rs %f\n",gs);

return 0;
}

QUES 2 WRITE A C PROGRAM TO INPUT ELECTRICITY UNIT CHARGES AND


CALCULATE 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 SUBCHARGE OF 20% IS ADDED TO THE BILL
#include<stdio.h>

int main()
{
int unit;
float total,subcharge;

printf("enter electricity consumption \n");


scanf("%d",&unit);

if (unit<=50)
{
total= unit*0.5;
}
else if (unit<=150)
{
total=(50*0.5)+((unit-50)*0.75);
}
else if (unit<=250)
{
total=(50*0.5)+(100*0.75)+((unit-150)*1.20);
}

else if (unit>250)
{
total=(50*0.5)+(100*0.75)+(100*1.20)+((unit-250)*1.50);

}
subcharge=total+total*0.2;
printf("total bill is: %0.2f",total);
return 0;
}

QUES 3. WRITE A PROGRAM TO FIND THE GREATEST OF THREE NUMBERS


INPUT BY USER
#include<stdio.h>

int main()
{
int a,b,c;
printf("enter three numbers\n");
scanf("%d %d %d",&a,&b,&c);

if ((a>b)&&(a>c))
{
printf("a is larger\n");
}
else if ((b>a)&&(b>c))
{
printf("b is larger\n") ;
}
else
{
printf(" c is larger") ;

return 0;
}

You might also like