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

Que 1

Uploaded by

by2qrjttr2
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)
14 views5 pages

Que 1

Uploaded by

by2qrjttr2
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

Que 1.

Write a c program to input basic salary of an employee and calculate its


gross salary according to the given conditions:
 Salary <=10000 ; HRA = 20% ; DA = 20% ,
 Salary <=20000 ; HRA = 25% ; DA = 90% ,
 Salary > 20000 ; HRA = 30% ; DA = 95%

Ans.
#include<stdio.h>

int main(){

int basicpay,grossalary,HRA,DA;

printf("Enter your basic pay : ");

scanf("%d",&basicpay);

if(basicpay<=10000){

HRA = (20*basicpay)/100;

DA = (80*basicpay)/100;

grossalary = basicpay + HRA + DA ;

printf("The net salary is: %d",grossalary);

else if(basicpay<=20000){

HRA = (25*basicpay)/100;

DA = (90*basicpay)/100;

grossalary = basicpay + HRA + DA ;

printf("The net salary is: %d",grossalary);

else{

HRA = (30*basicpay)/100;

DA = (95*basicpay)/100;

grossalary = basicpay + HRA + DA ;

printf("The net salary is: %d",grossalary);

}
return 0;

OUTPUT :

Que 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 surcharge of 20% is added to the bill

Ans.
#include<stdio.h>

int main(){

float n,a,b,c,d,e,f;

printf("Enter the total units");

scanf("%f",&n);

if(n<=50){

a = n*0.50 ;

b = (20*a)/100;

c =a + b;

printf("The net bill is %.2f",c);

else if(n>50 && n<=150){

b = 50*0.50;
n = n - 50;

c = n*0.75;

d = b+c ;

e = (20*d)/100 ;

f = d + e;

printf("The net bill is : %.2f",f);

else if(n>150 && n<=250){

a = 50*0.50;

n = n - 150;

c = 100*0.75;

b = n*1.2;

d = a+c+b ;

e = (20*d)/100;

f = d + e;

printf("The net bill is : %.2f",f);

else{

a = 50*0.50;

b = 100*0.75;

c = 100*1.20;

n = n-250;

d = n*1.50;

e = a+b+c+d;

f = (20*e)/100 + e ;

printf("The net bill is : %.2f",f);

return 0;

}
Output:

Que 3. Write a program to find the greatest of three number input by the user.
Ans.
#include<stdio.h>

int main(){

int a,b,c;

printf("enter first number:");

scanf("%d",&a);

printf("enter second number:");

scanf("%d",&b);

printf("enter third number:");

scanf("%d",&c);

if(a>b){

if(a>c)

printf("%d is the greatest number",a);

else if(b>c)

printf("%d is the greatest number",b);

else

printf("%d is the greatest number",c);

return 0;
}

Output

You might also like