Docsity

Bahria university OOP Assignment 1, Assignments of Computer Science

Partial preview of the text

Download Bahria university OOP Assignment 1 and more Assignments Computer Science in PDF only on Docsity!

TASK 1:

#include using namespace std; void sum(int a,int b) { cout<<"The sum of"<<a<<"and"<<b<<"is="<<a+b<<endl; } int main(){ int x,y; cout<<"Enter First Value="; cin>>x; cout<<"Enter Second Value="; cin>>y; sum(x,y); return 0; }

TASK 2:

#include using namespace std; void sum(int , int); void sub(int , int); void mul(int , int); void div(int , int); int main(){ int x,y; cout<<"Enter First Value="; cin>>x; cout<<"Enter Second Value="; cin>>y; sum(x,y); sub(x,y); mul(x,y); div(x,y); return 0; } void sum(int a,int b) { cout<<"The sum of "<<a<<" and "<<b<<" is = "<<a+b<<endl; } void sub(int a,int b) { cout<<"The sub of "<<a<<" and "<<b<<" is = "<<a-b<<endl;

cout<<"Enter First Value="; cin>>x; cout<<"Enter Second Value="; cin>>y; cout<<"The sum of "<<x<<" and "<<y<<" is = "<<sum(x,y)<<endl; cout<<"The sub of "<<x<<" and "<<y<<" is = "<<sub(x,y)<<endl; cout<<"The mul of "<<x<<" and "<<y<<" is = "<<mul(x,y)<<endl; cout<<"The div of "<<x<<" and "<<y<<" is = "<<div(x,y)<<endl; return 0; } int sum(int a,int b) { return (a+b); } int sub(int a,int b) { return (a-b); } int mul(int a,int b) { return (a*b); } int div(int a,int b) { return (a/b); }

TASK 4:

#include using namespace std; int sum(int , int); int sub(int , int); int mul(int , int); int div(int , int); int main(){ int x,y; int result; cout<<"Enter First Value="; cin>>x; cout<<"Enter Second Value="; cin>>y; cout<<"The sum of "<<x<<" and "<<y<<" is = "<<result<<endl; result=sum(x,y); cout<<"The sub of "<<x<<" and "<<y<<" is = "<<result<<endl; result=sub(x,y); cout<<"The mul of "<<x<<" and "<<y<<" is = "<<result<<endl; result= mul(x,y); cout<<"The div of "<<x<<" and "<<y<<" is = "<<result<<endl; result=div(x,y); return 0;