This is C program that asks user to find out the discount against salary. User declares the variables for storing the value in it. Here user asks to put the basic salary for finding out the discount against salary. For this procedure user declares the nested if-else condition. if(a==1000) then the discount will be 200 and if a=1500 then 500 and at the else condition no discount will be printing on the screen a s result as per. Here nested if-else condition comes into the lime light.
Problem Statement:
This is C program that asks user to find out the discount against the salary.
- Declaring the variables.
- Using if-else condition.
- Display result on the screen.
Here is C source code for calculate the discount against the salary. Output of this program shown below.
#include<stdio.h>
void main()
{
int a,discount;
clrscr();
printf("Enter Basic Salary :");
scanf("%d",&a);
if(a==1000)
{
discount=200;
printf("Discount : %d",discount);
}
else if(a==1500)
{
discount=500;
printf("Discount : %d",discount);
}
else if(a==2500)
{
discount=700;
printf("Discount : %d",discount);
}
else
{
printf("No Discount");
}
getch();
}