16) Income Tax:
Upto 250000 tax-0%
400001 to 500000 tax-10%
500001 to 1000000 tax-20%
Above 1000001 tax- 30%
#include<stdio.h>
#include<conio.h>
int main()
float i,t;
printf("Enter Income Tax :\n");
scanf("%f",&i);
if(i <=250000)
{
t=0;
else if(i >=250001 && i <=500000)
t=0+(i-250000)*10.0/100.0;
else if(i >=500001 && i <=1000000)
t=0+25000+(i-500000)*20.0/100.0;
else if(i >1000000)
t=0+25000+100000+(i-1000000)*30.0/100.0;
}
printf("Tax Payable :%f\n",t);
getch();
return 0;
}
17) WAP to calculate the time period of a time period of a simple
pendulum by taking length and acceleration due to gravity as inputs.
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
double l,g,t;
printf("enter length below:\n");
scanf("%lf",&l);
printf("enter acceleration due to gravity\n");
scanf("%lf",&g);
t=2.0*22.0/7.0*sqrt(l/g);
printf("time period:%lf\n",t);
getch();
return 0;
18) Check factorial.
#include<stdio.h>
#include<conio.h>
int main()
clrscr();
int f=1,n;
printf("Enter Number :\n");
scanf("%d",&n);
while(n !=0)
f=f*n;
--n;
printf("Factorial :%d\n",f);
getch();
return 0;
}
19) Even & Odd checking.
#include<stdio.h>
#include<conio.h>
int main()
int n;
printf("Enter Loop Bound :\n");
scanf("%d",&n);
for(int i=1;i<=n;i++)
if(i%2 ==0)
printf("Even :%d\n",i);
}
else if(i%2 ==1)
printf("Odd :%d\n",i);
getch();
return 0;
}
20) Print sum of n even number.
#include<stdio.h>
#include<conio.h>
int main()
int n,s1=0,s2=0;
printf("Enter Loop Bound :\n");
scanf("%d",&n);
for(int i=1;i<=n;i++)
if(i%2 ==0)
s1=s1+i;
}
printf("Sum Of Even :%d\n",s1);
getch();
return 0;
}
21) Print sum of n odd number.
#include<stdio.h>
#include<conio.h>
int main()
clrscr();
int n,s1=0,s2=0;
printf("Enter Loop Bound :\n");
scanf("%d",&n);
for(int i=1;i<=n;i++)
if(i%2 ==1)
s1=s1+i;
}
}
printf("Sum Of Odd :%d\n",s1);
getch();
return 0;
22) Print sum of n natural number.
#include<stdio.h>
#include<conio.h>
int main()
int n,s=0;
printf("Enter Loop Bound :\n");
scanf("%d",&n);
for(int i=1;i<=n;i++)
printf("%d\n",i);
s=s+i;
printf("Sum :%d\n",s);
getch();
return 0;
}
23) check composite number.
#include<stdio.h>
#include<conio.h>
int main()
clrscr();
int n,j,c=0;
printf("Enter A Number(Loop Bound) :\n");
scanf("%d",&n);
printf("Enter Number For Checking :\n");
scanf("%d",&j);
for(int i=1;i<=n;i++)
if(j%i ==0)
{
c++;
if(c ==2)
printf("Prime ");
else
printf("Composite");
getch();
return 0;
}
24) WAP to find the gross and net salary.
Allowance/deduction Rate
Dearness Allowance 30% of basic pay
House Rent Allowance 15% of basic pay
Provident Fund 12.5% of basic pay
#include<stdio.h>
#include<conio.h>
int main()
double da,hra,pf,basic,net, gross;
printf("Enter Basic Salary :\n");
scanf("%lf",&basic);
da=30.0/100.0*basic;
hra=15.0/100.0*basic;
pf=12.5/100.0*basic;
gross=da+hra+basic;
net=gross-pf;
printf("Basic Salary :%lf\n",gross);
printf("Net Salary :%lf\n",net);
getch();
return 0;
25) Find sum and average of three subjects.
#include<stdio.h>
#include<conio.h>
int main()
double p,c,b;
double sum,avg;
printf("Enter Marks Of Three Subjects :\n");
scanf("%lf",&p);
scanf("%lf",&c);
scanf("%lf",&b);
sum=(p+c+b);
avg=(sum)/3.0;
printf("Sum :%lf\n",sum);
printf("Average :%lf\n",avg);
getch();
return 0;
}
26) Check a triangle using three sides.
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
int a,b,c;
printf("Enter Sides Of Triangle :\n");
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
if(a <90 && b<90 && c ==90)
printf("Right Angled Triangle");
}
else if(a >90 && b >90 && c !=90)
printf("Not Possible");
else if(a <90 && b <90 && c <90)
printf("Acute Angled Triangle");
else if(a >90 && b >90 && c >90)
printf("Not Possible");
else if(a <90 && b <90 && c >90)
printf("Obtuse Angled Triangle");
}
else if(a >90 && b >90 && c <90)
printf("Not Possible");
getch();
return 0;
27) Using loop print my name.
#include<stdio.h>
#include<conio.h>
int main()
for(int i=1;i<=10;i++)
printf("My Name Is Soumyadeep Das\n");
getch();
return 0;
}
28)Using ternary operator , find greatest.
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
int a,b,c,d,e,f;
printf("Enter Three Number :\n");
scanf("%d %d %d",&a,&b,&c);
d=(a >b && a >c)?a:b && (b >a && b>c)?b:c && (c >a && c>b)?c:a; //
ternary operator
printf("Greatest :%d\n",d);
getch();
return 0;
}
29)WAP to find out a number which is even or odd.
#include<stdio.h>
#include<conio.h>
int main()
int n;
printf("Enter A Number :\n");
scanf("%d",&n);
if(n%2 ==0)
printf("Even");
else if(n%2 ==1)
printf("Odd");
}
getch();
return 0;
30) WAP to input three numbers and check whether they are equal or
[Link] they are unequal numbers then display the greatest among them
otherwise,display the message “all the numbers are equal”.
#include<stdio.h>
#include<conio.h>
int main()
clrscr();
int a,b,c;
printf("Enter Three Number :\n");
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
if(a==b && a ==c)
printf("Equal");
else if(a >b && a >c && b<a && b <c)
{
printf("Greatest Number :%d\n",a);
printf("Smallest Number :%d\n",b);
else if(b >a && b >c && c <a && c <b)
printf("Greatest Number :%d\n",b);
printf("Smallest Number :%d\n",c);
else if(c >a && c >b && a <b && a <c)
printf("Greatest Number :%d\n",c);
printf("Smallest Number :%d\n",a);
else
{
printf("Oops Sorry Check input");
getch();
return 0;
31) WAP to accept a no. and check whether the no. is divisible by 3 & 5
Otherwise decide:
(a)is the no. is divisible by 3 and not by 5.
(b)is the no. is divisible by 5 and not by 3.(c)is the no. is neither divisible by 3 nor by 5.
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
int num;
printf("enter the number to check\n");
scanf("%f",&num);
if(num%3==0 && num%5==0)
printf("is the no. is divisible by 3 & 5");
else if(num%5==0 && num%3!=0)
printf("is the no. is divisible by 5 and not by 3");
else if(num%3!=0 && num%5!=0)
printf("is the no. neither divisible by 3 nor by 5");
return 0;
getch();
}
32) WAP to input three numbers and check whether they are equal or
not. If they are equal or not then display greatest among
them ,otherwise ,display the message “all the numbers are equal”.
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
int a,b,c;
printf("enter three number:\n");
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
if(a==b && b==c && c==a)
printf("all the no. are equal:\n");
else if(a>b && a>c)
printf("greatest number:%d\n",a);
else if(b>a && b>c)
printf("greatest number:%d\n",b);
else if(c>a && c>b)
printf("greatest number:%d\n",c);
else
printf("they are not equal:\n",a);
return 0;
getch();
}
33) WAP to input year and check whether it is:(a) leap year(b)century
year(c)century year but not a leap year.
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
int y;
printf("enter a year to check:\n");
scanf("%d",&y);
if(y%4==0)
printf("%d is a leap year:\n",y);
else if(y%400==0)
printf("%d is a century leap year:\n",y);
else if(y%400==0 && y%4!=0)
printf("%d is a century year but not a leap year:\n",y);
return 0;
getch();
}
34) WAP to input the total cost. Compute and display the amount to be
paid by the customer along with the gift.
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
float a,d,dp;
printf("enter the amount:\n");
scanf("%f",&a);
if(a<=2000)
d=5/100*a;
printf("calculator:\n");
}
else if(a>=2001 && a<=5000)
d=10/100*a;
printf("school bag:\n");
else if(a>=5001 && a<=10000)
d=15/100*a;
printf("wall clock:\n");
else if(a>=10000)
d=20/100*a;
printf("wrist watch:\n");
}
dp=a-d;
printf("%f",d);
printf("%f",dp);
return 0;
getch();
35) WAP to input the distance covered and calculate the amount paid by the
passenger. The program displays the printed bill with details given below:
Taxi no:
Distance covered:
Amount:
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
int d,a,n;
for(int i=1;;i++)
printf("Enter Distance You Intended To Travel :\n");
scanf("%d",&d);
printf("Enter Number Of Passenger :\n");
scanf("%d",&n);
if(d <=5)
a=d*80;
}
else if(d >=10)
a=400+(d-10)*10;
else if(d >=15)
a=400+100+(d-15)*8;
printf("Number Of Passenger Travelled :%d\n",n);
printf("Total Fare Received :%d\n",a);
return 0;
getch();
}