0% found this document useful (0 votes)
34 views13 pages

Comp218: European University of Lefke Faculty of Engineering Department of Computer Engineering

Uploaded by

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

Comp218: European University of Lefke Faculty of Engineering Department of Computer Engineering

Uploaded by

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

EUROPEAN UNIVERSITY OF LEFKE

Faculty of Engineering
Department of Computer Engineering

Comp218
OBJECT-ORIENTED PROGRAMMING

Lab Work No. 2

Prepared by Hilmi Tunahan Cigil

(20120081)

Submitted to Salman Khan


Task 1 :

A)
#include<iostream>
using namespace std;

int main(void)
{
float a,b,c,d,e,sum;
cout<< "enter 5 float value : ";
cin>>a>>b>>c>>d>>e;
cout<<endl;
sum = a+b+c+d+e;
cout<<"result : "<<sum<<endl;
}
b)
#include<iostream>
using namespace std;

int main()
{
int a,b,c,d,e,f;
cout<<"enter 5 value"<<endl;
cin>>a>>b>>c>>d>>e;

if(a<b && a<c && a<d && a<e)


{
cout<<a<< "is smalest one"<<endl;
}
else if(b<a && b<c && b<d && b<e)
{
cout<<b<<" is smalest one";
}
else if(c<a && c<b && c<d && c<e)
{
cout<<c<<" is smalest one";
}
else if(d<a && d<c && d<b && d<e)
{
cout<<d<<" is smalest one";
}
else if(e<a && e<c && e<d && e<b)
{
cout<<e<<" is smalest one";
}
}
c)

#include<iostream>
using namespace std;
int main(void)
{
int n,m,result=1;

cout<<"enter base and power : ";


cin>>m>>n;
cout<<endl;
for (int i = 0; i < n; i++)
{
result*=m;
}
cout<<"m power of n is = "<<result<<endl;

}
Task 2

#include<iostream>
using namespace std;

int main(void)
{

while (6)
{
float a,b;
int secim;
cout<<"1 add: "<<endl;
cout<<"2 Subtract"<<endl;
cout<<"3 multiply"<<endl;
cout<<"4 quit"<<endl;

cin>>secim;

switch (secim)
{

case 1:
cout<<"enter two value : "<<endl;
cin>>a>>b;
cout<<"addition of "<<a<<" and "<<b<<" is = " <<a+b<<endl<<endl;
break;

case 2:
cout<<"enter two value : "<<endl;
cin>>a>>b;
cout<<"result of subtraction is = "<< a-b<<endl<<endl;
break;

case 3:
cout<<"enter two value : "<<endl;
cin>>a>>b;
cout<<"result of multiplication is "<<a*b<<endl<<endl;
break;

case 4:
cout<<"logging out"<<endl;
cout<<"logged out";
return 0;

default:
break;
}
}

}
Task 3)

#include<iostream>
using namespace std;

int main()
{

float a,b;
char secim;
cout<<"+ add "<<endl;
cout<<"- Subtract "<<endl;
cout<<"' multiply"<<endl;
cout<<". quit"<<endl;
cout << "Enter your choice (+, -, *, or .): ";
cin>>secim;

while (secim != '.')


{

switch (secim)
{

case '+':
cout<<"enter two value : "<<endl;
cin>>a>>b;
cout<<"addition of "<<a<<" and "<<b<<" is = "
<<a+b<<endl<<endl;
break;

case '-':
cout<<"enter two value : "<<endl;
cin>>a>>b;
cout<<"result of subtraction is = "<< a-b<<endl<<endl;
break;

case '*':
cout<<"enter two value : "<<endl;
cin>>a>>b;
cout<<"result of multiplication is "<<a*b<<endl<<endl;
break;

default:
cout << "Invalid choice." << endl;
break;

}
cout << "Enter your choice (+, -, *, or .): ";
cin >> secim;
if (secim == '.' )
{
cout<<"logging out"<<endl;
cout<<"logged out";
}
}
return 0;
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy