Programming in C++ 3330702 (Practical-No) : - Explain Basic Concepts of Object-Oriented Programming
Programming in C++ 3330702 (Practical-No) : - Explain Basic Concepts of Object-Oriented Programming
3330702
[PRACTICAL-NO]
•Explain basic concepts of object-oriented programming.
1. Write a C++ program to find the older brother out of given the age
of two brothersusing functions.(Call by value).
#include<iostream>
int findOlder(int,int);
int main()
int p,d;
cin>>p;
cin>>d;
if(p==findOlder(p,d))
else
return 0;
{
if(age1 > age2)
return age1;
else
return age2;
Output -
int main()
int a=11,b=22;
cout<<"Befor swapping"<<endl;
cout<<"A= "<<a<<endl;
cout<<"B= "<<b<<endl;
swap(a,b);
cout<<"After swapping"<<endl;
cout<<"A= "<<a<<endl;
cout<<"B= "<<b<<endl;
return 0;
x=x+y;
y=x-y;
x=x-y;
Output -
3. Write a C++ program to find the older brother out of given the age
of two brothers using functions. (Use Return by reference).
#include<iostream>
int main()
int x,y;
cin>>x;
cin>>y;
if(x==OlderBrother(x,y))
else
return 0;
if(x > y)
return x;
else
{
return y;
Output -
return n*n*n;
int main()
cout<<"cube :"<<cube(5);
return 0;
}
Output -
return p*n*r;
int main()
return 0;
Output -
#define pi 3.14
double area(int a)
return a*a;
return b*l;
double area(float r)
return pi*r*r;
int main()
int a,b,l;
float r;
cin>>a;
cin>>b>>l;
cin>>r;
return 0;
Output -
#define pi 3.14
int volume(int a)
return a*a*a;
{
return pi*r*r*h;
return l*b*h;
int main()
return 0;
Output -
#include<cmath>
int main()
{
double a,b,c;
a=121;
b=7;
c=3;
return 0;
Output -