BASIC:<150000 TAX :0%
150000 to 300000 TAX :20%
>300000 TAX :30%
#include<stdio.h>
main()
{
int ab;
int tax;
printf("Enter your annual basic salary");
scanf("%d",&ab);
if(ab<150000)
printf("Tax=0");
else if(150000<=ab<=300000)
{
tax=0.2*ab;
printf("tax=%d",tax);
}
else
{
tax=0.3*ab;
printf("tax=%d",tax);
}
}
ASSIGNMENT 2)
TO DEMONSTRATE USE OF DECISION MAKING STATEMENTS SUCH AS if AND if-else
You should read following topics before starting this exercise
1. Different types of decision making statements available in C.
2. Syntax for this statements.
i ) if statements
Syntax = if (condition)
{
statement;
}
ii ) if-else
Syntax = if (condition)
{
statement;
}
else
{
statement;
}
iii ) Nested if
if (condition)
{
if (condition)
{ statement; }
else
{ statement; }
}
else
{
if (condition)
{ statement; }
else
{ statement; }
}
150000 to 300000 TAX :20%
>300000 TAX :30%
#include<stdio.h>
main()
{
int ab;
int tax;
printf("Enter your annual basic salary");
scanf("%d",&ab);
if(ab<150000)
printf("Tax=0");
else if(150000<=ab<=300000)
{
tax=0.2*ab;
printf("tax=%d",tax);
}
else
{
tax=0.3*ab;
printf("tax=%d",tax);
}
}
ASSIGNMENT 2)
TO DEMONSTRATE USE OF DECISION MAKING STATEMENTS SUCH AS if AND if-else
You should read following topics before starting this exercise
1. Different types of decision making statements available in C.
2. Syntax for this statements.
i ) if statements
Syntax = if (condition)
{
statement;
}
ii ) if-else
Syntax = if (condition)
{
statement;
}
else
{
statement;
}
iii ) Nested if
if (condition)
{
if (condition)
{ statement; }
else
{ statement; }
}
else
{
if (condition)
{ statement; }
else
{ statement; }
}
No comments:
Post a Comment