0% found this document useful (0 votes)
23 views7 pages

Document 5

Uploaded by

icclothingg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views7 pages

Document 5

Uploaded by

icclothingg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 7

Task (1)

#include <iostream>
#include <conio.h>
using namespace std;
int main() {
int a,b;
cout<<"Enter first number\t";
cin>>a;
cout<<"\nEnter second number";
cin>>b;
if (a==b) {
cout<<"They are equal";
}
else {
cout<<"They are not equal";
}
return 0;
}

Task (2)
#include <iostream>
#include <conio.h>
using namespace std;
int main() {
int a;
cout<<"Enter the number";
cin>> a;
if (a%2==1) {
cout<<"odd";
}
else {
cout<<"even";
}
return 0;
}

Task (3)
#include <iostream>
#include <conio.h>
using namespace std;
int main() {
int a;
cout<<"Enter the number";
cin>>a;
if (a==0) {
cout<<"zero";
}
if (a==1) {
cout<<"one";
}
if (a==2) {
cout<<"two";
}
if (a==3) {
cout<<"three";
}
if (a==4) {
cout<<"four";
}
if (a==5) {
cout<<"five";
}
if (a==6) {
cout<<"six";
}
if (a==7) {
cout<<"seven";
}
if (a==8) {
cout<<"eight";
}
if (a==9) {
cout<<"nine";
}
if (a==10) {
cout<<"ten";
}
return 0;
}

Task (4)
#include <iostream>
#include <conio.h>
using namespace std;
int main() {
int a;
cout<<"Enter the year";
cin>>a;
if (a%4==0) {
cout<<"it is a leap year";
}
else {
cout<<"it is not a leap year";
}
return 0;
}

Task (5)
#include <iostream>
#include <conio.h>
using namespace std;
int main() {
int a;
cout<<"Enter the age";
cin>>a;
if (a>=18) {
cout<<"Eligible for vote ";
}
else {
cout<<"Not eligible for vote";
}
return 0;
}

Task (6)
#include <iostream>
#include <conio.h>
using namespace std;
int main() {
int a,b,c;
cout<<"Enter first number";
cin>>a;
cout<<"\nEnter second number";
cin>>b;
cout<<"\nEnter third number";
cin>>c;
if (a>b&&a>c) {
cout<<"First number is the greatest";
}
if (b>a&&b>c) {
cout<<"Second number is the greatest";
}
else {
cout<<"Third number is the greatest";
}
return 0;
}

Task (7)
#include <iostream>
#include <conio.h>
using namespace std;
int main() {
int p,Purchase_price,selling_price;
cout<<"Enter the purchase price";
cin>>Purchase_price;
cout<<"\nEnter the selling price";
cin>>selling_price;
if (0<=selling_price-Purchase_price) {
cout<<"Profit";
}
else {
cout<<"Loss";
}
return 0;
}

Task (9)
#include <iostream>
#include <conio.h>
using namespace std;
int main() {
int a;
cout<<"Enter the number";
cin>>a;
if (a>0) {
cout<<"Positive";
}
if (a<0) {
cout<<"Negative";
}
if (a==0){
cout<<"Nutral";
}
return 0;
}

Task (10)
#include <iostream>
#include <conio.h>
using namespace std;
int main() {
int a;
cout<<"Enter the month number";
cin>>a;
if (a==1) {
cout<<"January";
}
if (a==2) {
cout<<"February";
}
if (a==3) {
cout<<"March";
}
if (a==4) {
cout<<"April";
}
if (a==5) {
cout<<"May";
}
if (a==6) {
cout<<"June";
}
if (a==7) {
cout<<"July";
}
if (a==8) {
cout<<"August";
}
if (a==9) {
cout<<"September";
}
if (a==10) {
cout<<"October";
}
if (a==11) {
cout<<"November";
}
if (a==12) {
cout<<"December";
}
if (a>12) {
cout<<"Month number is not correct";
}
return 0;
}

Task (12)
#include <iostream>
#include <conio.h>
using namespace std;
int main() {
char op;
int a,b,r;
cout<<"Enter first number";
cin>>a;
cout<<"Enter second number";
cin>>b;
cout<<"which operation";
cin>>op;
if ( op =='+' ) {
r=a=b;
cout<<r;
}
if (op=='-') {
r=a-b;
cout<<r;
}
if (op=='*') {
r=a*b;
cout<<r;
}
if (op=='/') {
r=a/b;
cout<<r;
}
return 0;
}

You might also like