Exp 3

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Ex.No.

3
Usage of conditional statements Reg.No: URK22CS5043
20.10.2022

a) Write a program to calculate the gross salary for the conditions given

Aim:
To calculate gross salary for the condition given below

Algorithm:
Step 1: Start the program.
Step 2: Input Basic, hra, da, con
Step 3: Read the input values from the condition
Step 4: Gross = basic + hra + da + con
Step 5: Print gross salary.
Step 6: Stop the Program.

Program:

#include <stdio.h>
int main ()
{
float basic, gross, da, hra, con;
printf ("Enter basic salary of an employee: ");
scanf ("%f", &basic);
if (basic >= 5000)
{
da = basic * 0.110;
hra = basic * 0.20;
con = 500;
}
else if (basic >= 3000 && basic < 5000)
{
da = basic * 0.100;
hra = basic * 0.15;
con = 400;
}
else
{
da = basic * 0.90;
hra = basic * 0.10;
con = 300;
}
gross = basic + hra + da + con;
printf ("GROSS SALARY OF EMPLOYEE = %.2f", gross);
return 0;
}

Output:

Result:
This program is executed successfully and the gross salary of an employee is obtained.

b) Write a program to calculate the tax, given the following conditions.


a. If income is less than 1,50,000 then no tax
b. It taxable income is in the range of 1,50,001 – 3,00,000 then charge 10% of income as
tax
c. It taxable income is in the range of 3,00,001 – 5,00,000 then charge 20% of income as
tax
d. If taxable income is above 5,00,001 then charge 30% of income as tax

Aim:
To calculate the tax from the given conditions

Algorithm:
Step 1: Start the program.
Step 2: Int income, tax
Step 3: Read the income by the following conditions
Step 4: Tax = Following condition * Income
Step 5: Print tax.
Step 6: Stop the Program.

Program:
#include<stdio.h>
int main()
{
float tax ,income;
printf ("enter your income \n");
scanf ("%f", &income);
if (income <= 150000)
{
tax = 0.00 * (income);
}
else if (income >= 150001 && income <= 300000)
{
tax = 0.10 * (income);
}
else if (income >= 300001 && income <= 500000)
{
tax = 0.20 * (income);
}
else (income >= 500001);
{
tax = 0.30 * (income);
}
printf ("your tax = %.2f \n", tax);
return 0;
}

Output:

Result:
This program is executed successfully and tax is obtained

You might also like