SET – 2
1.Write a program to check whether the person is eligible to vote or not.
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
cout<<”enter age”;
cin>>a;
if(a>=18)
cout<<”Eligible”;
else
cout<<”not Eligible”;
getch();
}
2.Write a program to check whether the person is rich or poor on his salary. If the salary is less than or equal to 10000 consider him poor else rich.
#include<iostream.h>
#include<conio.h>
void main()
{
int s;
cout<<”enter salary”;
cin>>s;
if(s<=10000)
cout<<”poor”;
else
cout<<”rich”;
getch();
3. Write a program to check whether the person will get commission on no commission on his Sales. If sales is greater than 50000 he will get commission else no commission.
#include<iostream.h>
#include<conio.h>
void main()
{
int s;
cout<<”enter sales”;
cin>>s;
if(s>50000)
cout<<”he will get commission ”;
else
cout<<”he will not get commission”;
getch();
}
4. Write a program to check whether the person is eligible to vote or not. If the person is not eligible to vote find out how many years he has to wait.
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
cout<<”enter the age of the person”;
cin>>a;
if(a<=18)
cout<<”he/she have to wait”<<(18-a);
else
cout<<”eligible for vote”;
getch();
}
5. Write a program to check whether the student has passed or failed on his marks. If yhe total mark is greater than or equal to 180 consider his pass or else fail.
#include<iostream.h>
#include<conio.h>
void main()
{
inta,b,c,d;
cout<<”enter the first mark”;
cin>>a;
cout<<”enter the second mark”;
cin>>b;
cout<<”enter the third mark”;
cin>>c;
d=a+b+c;
if(d>=180)
cout<<”pass”;
else cout<<”fail”;
getch();
}
6. Write a program to check whether the number is odd or not.
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
cout<<”enter the number”;
cin>>a;
if(a%2==0)
cout<<”even number”;
else
cout<<”odd”;
getch();
}
7. Write a program to check whether the number is divisible by 5 or not.
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
cout<<”enter the number”;
cin>>a;
if(a%5==0)
cout<<”divisible by 5”;
else
cout<<”not divisible by 5”;
getch();
}
8. Write a program whether the year is leap year or not.
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
cout<<”enter the year”;
cin>>a;
if(a%4==0)
else if(a%100==0)
else if(a%400==0)
cout<<”leap year”;
else
cout<<”not a leap year”;
getch();
}
9. Write a program to check whether the number is odd or not. If the number is odd than check that it is divisible by 7 or not.
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
cout<<”enter the number”;
cin>>a;
if(a%2!=0)
{
if(a%7==0)
cout<<”divisible by 7”;
}
cout<<”odd”;
else
cout<<”even”;
getch();
}
10. Write a program to check whether the person has made profit or loss or no profit or loss. If the cost price and selling price is entered by user.
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
cout<<”enter cost price”;
cin>>a;
cout<<”enter selling price”;
cin>>b;
if(a>b)
cout<<”loss”;
else
cout<<”profit”;
getch();
}
17. Write a program to find out the greatest angle of the triangle if the angles is given by the user
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c,max;
cout<<"Enter the three angles of the triangle";
cin>>a>>b>>c;
max=a>b?(a>c?a:c):(b>c?b:c);
cout<<"The greatest angle of the triangle is<<" "<<max;
getch();
}
19. Write a program to find the bill for the telephone. The telephone charges Rs. 275 from all households and allows 100 units free. If the unit exceeds 100 Rs. 2.00 is charged for extra unit above 100 along with Rs. 275
#include<iostream.h>
#include<conio.h>
void main()
{
double u,b;
cout<<"enter units consumed";
cin>>u;
if(u<=100)
b=275;
else
b=275+(u-100)×2.00;
cout<<"final bill";
getch();
}
20. Write a program to find the traveling allowance for a employee. The company gives the traveling allowance on the following table
Distance Amount
<=20 Rs. 200
>20 & <=50 Rs 200 + Rs 3 per extra kilometer above 20
>50 & <=100 Rs 500 + Rs 3 per extra kilometer above 50
>100 Rs 10 per kilometer
#include<conio.h>
void main()
{
int d,b;
cout<<"enter distance";
cin>>d;
if(d<=20)
b=200;
else if(d>20&&d<=50)
b=200+(d-20)×3;
else if(d>50&&d<=100)
b=500+(d-50)×3;
else
b=d×10;
cout<<"final bill";
getch();
}
22. Write a program to find whether a person is child, teen, youth, or old on his age. If his age is less than 14 consider is as child, between 14 to 20 both inclusive teen, between 21 to 45 both inclusive youth and above 45 old
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
cout<<"enter age";
cin>>a;
if(a<14)
cout<<"child";
else if(a>14&&a<21)
cout<<"teen";
else if(a>25&&a<45)
cout<<"youth";
else
cout<<"old";
getch();
}
1.Write a program to check whether the person is eligible to vote or not.
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
cout<<”enter age”;
cin>>a;
if(a>=18)
cout<<”Eligible”;
else
cout<<”not Eligible”;
getch();
}
2.Write a program to check whether the person is rich or poor on his salary. If the salary is less than or equal to 10000 consider him poor else rich.
#include<iostream.h>
#include<conio.h>
void main()
{
int s;
cout<<”enter salary”;
cin>>s;
if(s<=10000)
cout<<”poor”;
else
cout<<”rich”;
getch();
3. Write a program to check whether the person will get commission on no commission on his Sales. If sales is greater than 50000 he will get commission else no commission.
#include<iostream.h>
#include<conio.h>
void main()
{
int s;
cout<<”enter sales”;
cin>>s;
if(s>50000)
cout<<”he will get commission ”;
else
cout<<”he will not get commission”;
getch();
}
4. Write a program to check whether the person is eligible to vote or not. If the person is not eligible to vote find out how many years he has to wait.
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
cout<<”enter the age of the person”;
cin>>a;
if(a<=18)
cout<<”he/she have to wait”<<(18-a);
else
cout<<”eligible for vote”;
getch();
}
5. Write a program to check whether the student has passed or failed on his marks. If yhe total mark is greater than or equal to 180 consider his pass or else fail.
#include<iostream.h>
#include<conio.h>
void main()
{
inta,b,c,d;
cout<<”enter the first mark”;
cin>>a;
cout<<”enter the second mark”;
cin>>b;
cout<<”enter the third mark”;
cin>>c;
d=a+b+c;
if(d>=180)
cout<<”pass”;
else cout<<”fail”;
getch();
}
6. Write a program to check whether the number is odd or not.
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
cout<<”enter the number”;
cin>>a;
if(a%2==0)
cout<<”even number”;
else
cout<<”odd”;
getch();
}
7. Write a program to check whether the number is divisible by 5 or not.
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
cout<<”enter the number”;
cin>>a;
if(a%5==0)
cout<<”divisible by 5”;
else
cout<<”not divisible by 5”;
getch();
}
8. Write a program whether the year is leap year or not.
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
cout<<”enter the year”;
cin>>a;
if(a%4==0)
else if(a%100==0)
else if(a%400==0)
cout<<”leap year”;
else
cout<<”not a leap year”;
getch();
}
9. Write a program to check whether the number is odd or not. If the number is odd than check that it is divisible by 7 or not.
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
cout<<”enter the number”;
cin>>a;
if(a%2!=0)
{
if(a%7==0)
cout<<”divisible by 7”;
}
cout<<”odd”;
else
cout<<”even”;
getch();
}
10. Write a program to check whether the person has made profit or loss or no profit or loss. If the cost price and selling price is entered by user.
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
cout<<”enter cost price”;
cin>>a;
cout<<”enter selling price”;
cin>>b;
if(a>b)
cout<<”loss”;
else
cout<<”profit”;
getch();
}
17. Write a program to find out the greatest angle of the triangle if the angles is given by the user
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c,max;
cout<<"Enter the three angles of the triangle";
cin>>a>>b>>c;
max=a>b?(a>c?a:c):(b>c?b:c);
cout<<"The greatest angle of the triangle is<<" "<<max;
getch();
}
19. Write a program to find the bill for the telephone. The telephone charges Rs. 275 from all households and allows 100 units free. If the unit exceeds 100 Rs. 2.00 is charged for extra unit above 100 along with Rs. 275
#include<iostream.h>
#include<conio.h>
void main()
{
double u,b;
cout<<"enter units consumed";
cin>>u;
if(u<=100)
b=275;
else
b=275+(u-100)×2.00;
cout<<"final bill";
getch();
}
20. Write a program to find the traveling allowance for a employee. The company gives the traveling allowance on the following table
Distance Amount
<=20 Rs. 200
>20 & <=50 Rs 200 + Rs 3 per extra kilometer above 20
>50 & <=100 Rs 500 + Rs 3 per extra kilometer above 50
>100 Rs 10 per kilometer
#include<conio.h>
void main()
{
int d,b;
cout<<"enter distance";
cin>>d;
if(d<=20)
b=200;
else if(d>20&&d<=50)
b=200+(d-20)×3;
else if(d>50&&d<=100)
b=500+(d-50)×3;
else
b=d×10;
cout<<"final bill";
getch();
}
22. Write a program to find whether a person is child, teen, youth, or old on his age. If his age is less than 14 consider is as child, between 14 to 20 both inclusive teen, between 21 to 45 both inclusive youth and above 45 old
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
cout<<"enter age";
cin>>a;
if(a<14)
cout<<"child";
else if(a>14&&a<21)
cout<<"teen";
else if(a>25&&a<45)
cout<<"youth";
else
cout<<"old";
getch();
}
No comments:
Post a Comment