One box have some apples and another box have some oranges, develop a C++ program to find the sum of fruits and double the sum of fruits in the box using call by address concept
#include <iostream>
using namespace std;
int SumFruit(const int& a, const int& b);
int DoubleInBox(int& a, int& b);
int main( )
{
int apples = 0;
int oranges = 0;
cout << "Enter number of apples in first box: ";
cin >> apples;
cout << "Enter number of oranges in second box: ";
cin >> oranges;
cout << "Sum of two boxes is: " << SumFruit(apples, oranges) << " fruits." << endl;
cout << "Double the sum of fruits in boxes is: " << DoubleInBox(apples, oranges) << endl;
return 0;
}
int SumFruit(const int& a, const int& b)
{
return a+b;
}
int DoubleInBox(int& a, int& b)
{
return (a + b) * 2;
}
Comments
Leave a comment