Professional Documents
Culture Documents
Exp 3
Exp 3
Exp 3
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.
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