Comp218: European University of Lefke Faculty of Engineering Department of Computer Engineering
Comp218: European University of Lefke Faculty of Engineering Department of Computer Engineering
Faculty of Engineering
Department of Computer Engineering
Comp218
OBJECT-ORIENTED PROGRAMMING
(20120081)
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;
#include<iostream>
using namespace std;
int main(void)
{
int n,m,result=1;
}
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;
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;
}