Nothing Special   »   [go: up one dir, main page]

Bokachoda

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

1.

#include<iostream>
using namespace std;
int main(){
int int1,int2;
cout << "Enter the first integer : ";
cin >> int1;
cout << "Enter the second integer : ";
cin >> int2;
if(int1==int2){
cout << "Both are equal";
}
else{
cout << "Both are not equal";
}
return 0;
}

2.
#include<iostream>
using namespace std;
int main(){
int int1;
cout << "Enter a number(integer only) : ";
cin >> int1;
if(int1%2==0){
cout << int1 <<" is even.";
}
else{
cout << int1 <<" is odd.";
}
return 0;
}
3.
#include<iostream>
using namespace std;
int main(){
float int1;
cout << "Enter a number : ";
cin >> int1;
if(int1>0){
cout << int1 <<" is positive.";
}
else if(int1<0){
cout << int1 <<" is negative.";
}
else{
cout << int1 <<" is neither odd nor even.";
}
return 0;
}
4.
#include<iostream>
using namespace std;
int main(){
int year;
cout << "Enter a year: ";
cin >> year;

if (year % 4 == 0) {
if (year % 100 == 0) {
if (year % 400 == 0)
cout << year << " is a leap year.";
else
cout << year << " is not a leap year.";
}
else
cout << year << " is a leap year.";
}
else
cout << year << " is not a leap year.";

return 0;

}
5.
#include<iostream>
using namespace std;
int main(){
int age;
cout << "Enter the age of candidate : ";
cin >> age;
if(age>=18){
cout << " Candidate is eligible to vote.";
}
else{
cout << " Candidate is not eligible to vote.";
}
return 0;
}
6.
#include<iostream>
using namespace std;
int main(){
int m,n;
cout << "Enter a number : ";
cin >> m;
if(m>0){
n=1;
cout << " n is "<< n <<" Since m is greater than 0 ";
}
else if(m<0){
n=-1;
cout << " n is "<< n <<" Since m is less than 0 ";
}
else{
n=0;
cout << " n is "<< n <<" Since m is equal to 0 ";
}
return 0;
}
7.

#include<iostream>
using namespace std;
int main(){
float height;
cout << "Enter the height of person(in centimeters only) : ";
cin >> height;
if (height < 150.0)
cout << "Dwarf";
else if ((height >= 150.0) && (height <= 165.0))
cout << "Average";
else if ((height > 165.0) && (height <= 195.0))
cout << "Tall";
else
cout << "Invalid height";
return 0;
}
8.
#include<iostream>
using namespace std;
int main(){
int num1,num2,num3,max;
cout <<"Enter first number : ";
cin >> num1;
cout <<"Enter second number : ";
cin >> num2;
cout <<"Enter third number : ";
cin >> num3;
if(num1>num2){
if(num1>num3){
max=num1;
}
else{
max=num3;
}
}
else{
if(num2>num3){
max=num2;
}
else{
max=num3;
}
}
cout << "The largest of three is: "<< max;
return 0;
}
9.
#include<iostream>
using namespace std;
int main(){
int x,y;
cout << "Enter x-value(either greater or lesser than 0) : ";
cin >> x;
cout << "Enter y-value(either greater or lesser than 0) : ";
cin >> y;
if(x>0 && y>0){
cout << "Point lies in first quadrant.";
}
else if(x<0 &&y>0){
cout << "Point lies in second quadrant.";
}
else if(x<0 && y<0){
cout << "Point lies in third quadrant.";
}
else{
cout << "Point lies in fourth quadrant.";
}
return 0;
}

You might also like