Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

NAME‌‌:-‌‌AYUSH‌‌ARVINDKUMAR‌‌RANA‌ 


ROLL‌‌NO.‌‌:-‌‌122‌  ‌
SEMESTER‌‌:-‌‌3 ‌ ‌
DIVISION‌‌:-‌‌B ‌ ‌
 ‌
 ‌
 ‌
1.‌‌Develop‌‌a‌‌program‌‌on‌‌function‌‌overloading‌‌by‌‌overloading‌‌the‌‌function‌‌called‌‌as‌‌sum(or‌‌add)‌‌to‌‌ 
perform‌‌five‌‌different‌‌functionalities.‌  ‌
 ‌
/*‌  ‌
‌*‌‌NAME‌‌:-AYUSH‌‌ARVINDKUMAR‌‌RANA‌  ‌
‌*‌‌ROLL‌‌NO.‌‌:-‌‌122‌  ‌
‌*/‌  ‌
#include<iostream>‌  ‌
using‌‌namespace‌‌std;‌  ‌
int‌‌add(int‌‌,‌‌int‌‌);‌  ‌
double‌‌add(double‌‌,‌‌double‌‌);‌  ‌
double‌‌add(double‌‌,‌‌int‌‌);‌  ‌
double‌‌add(int‌‌,‌‌double‌‌);‌  ‌
float‌‌add(float‌‌,float‌‌);‌  ‌
string‌‌add(string‌‌,string‌‌);‌  ‌
int‌‌main()‌  ‌
{‌  ‌
‌string‌‌s1="ayush";‌  ‌
‌string‌‌s2="rana";‌  ‌
‌cout‌‌<<‌‌"Addition‌‌of‌‌Integer:‌‌"‌‌<<‌‌add(26,24)‌‌<<‌‌"\n";‌  ‌
‌cout‌‌<<‌‌"Addition‌‌of‌‌Double:‌‌"‌‌<<‌‌add(4.44,5.55)‌‌<<‌‌"\n";‌  ‌
‌cout‌‌<<‌‌"Addition‌‌of‌‌Double,Integer:‌‌"‌‌<<‌‌add(9.9,6)‌‌<<‌‌"\n";‌  ‌
‌cout‌‌<<‌‌"Addition‌‌of‌‌Integer,Double:‌‌"‌‌<<‌‌add(5,2.5)‌‌<<‌‌"\n";‌  ‌
‌cout‌‌<<‌‌"Addition‌‌of‌‌floats:‌‌"‌‌<<‌‌add(6.5,5.6)‌‌<<‌‌"\n";‌  ‌
‌cout‌‌<<‌‌"Addition‌‌of‌‌string:‌‌"‌‌<<‌‌add(s1,s2)‌‌<<‌‌"\n";‌  ‌
‌return‌‌0;‌  ‌
}‌  ‌
int‌‌add(int‌‌a,‌‌int‌‌b)‌  ‌
{‌  ‌
‌return‌‌a‌‌+‌‌b;‌  ‌
}‌  ‌
 ‌
double‌‌add(double‌‌a,‌‌double‌‌b)‌  ‌
{‌  ‌
‌return‌‌a‌‌+‌‌b;‌  ‌
}‌  ‌
 ‌
double‌‌add(double‌‌a,‌‌int‌‌b)‌  ‌
{‌  ‌
‌return‌‌a‌‌+‌‌b;‌  ‌
}‌  ‌
double‌‌add(int‌‌a,‌‌double‌‌b)‌  ‌
{‌  ‌
‌return‌‌a‌‌+‌‌b;‌  ‌
}‌  ‌
float‌‌add(float‌‌a,‌‌float‌‌b)‌  ‌
{‌  ‌
‌return‌‌a‌‌+‌‌b;‌  ‌
}‌  ‌
string‌‌add(string‌‌a,string‌‌b)‌  ‌
{‌  ‌
‌return‌‌a‌‌+‌‌b;‌  ‌
}‌  ‌
/*‌  ‌
‌*‌‌NAME‌‌:-‌‌AYUSH‌‌ARVINDKUMAR‌‌RANA‌  ‌
‌*‌‌ROLL‌‌NO.‌‌:-‌‌122‌  ‌
‌*/‌  ‌
 ‌
 ‌
 ‌
 ‌
2.‌‌Develop‌‌a‌‌program‌‌on‌‌function‌‌overloading‌‌by‌‌overloading‌‌the‌‌function‌‌called‌‌as‌‌area‌‌to‌‌calculate‌‌ 
the‌‌area‌‌of‌‌circle,‌‌square‌‌and‌‌rectangle.‌  ‌
 ‌
 ‌
 ‌
/*‌  ‌
‌*‌ ‌NAME‌‌:-‌‌AYUSH‌‌ARVINDKUMAR‌‌RANA‌  ‌
‌*‌ ‌ROLL‌‌NO.‌‌:-‌‌122‌  ‌
‌*/‌  ‌
#include<iostream>‌  ‌
using‌‌namespace‌‌std;‌  ‌
float‌‌area(float);‌  ‌
float‌‌sarea(float);‌  ‌
float‌‌area(float‌‌,float);‌  ‌
int‌‌main()‌  ‌
{‌  ‌
float‌‌r,s,l,w;‌  ‌
cout‌‌<<‌‌"Enter‌‌radius‌‌of‌‌circle:";‌  ‌
cin‌‌>>‌‌r;‌  ‌
cout‌‌<<‌‌"Enter‌‌side‌‌value‌‌of‌‌square:";‌  ‌
cin‌‌>>‌‌s;‌  ‌
cout‌‌<<‌‌"Enter‌‌length‌‌and‌‌width‌‌of‌‌rectangle:";‌  ‌
cin‌‌>>‌‌l‌‌>>‌‌w;‌  ‌
cout‌‌<<‌‌"Area‌‌of‌‌circle:"‌‌<<‌‌area(r)‌‌<<‌‌"\n";‌  ‌
cout‌‌<<‌‌"Area‌‌of‌‌square:"‌‌<<‌‌sarea(s)‌‌<<‌‌"\n";‌  ‌
cout‌‌<<‌‌"Area‌‌of‌‌rectangle:"‌‌<<‌‌area(l,w)‌‌<<‌‌"\n";‌  ‌
return‌‌0;‌  ‌
}‌  ‌
float‌‌area(float‌‌r)‌  ‌
{‌  ‌
float‌‌pi=3.14;‌  ‌
return‌‌pi*r*r;‌  ‌
}‌  ‌
float‌‌sarea(float‌‌s)‌  ‌
{‌  ‌
return‌‌s*s;‌  ‌
}‌  ‌
float‌‌area(float‌‌l,float‌‌w)‌  ‌
{‌  ‌
return‌‌l*w;‌  ‌
}‌  ‌
/*‌  ‌
‌*‌ ‌NAME‌‌:-‌‌AYUSH‌‌ARVINDKUMAR‌‌RANA‌  ‌
‌*‌ ‌ROLL‌‌NO.‌‌:-‌‌122‌  ‌
‌*/‌  ‌
 ‌

You might also like