Use a function to get the user's keyboard values. Use another function to calculate the cubic feet. - C++ Function

C++ examples for Function:Function Parameter

Description

Use a function to get the user's keyboard values. Use another function to calculate the cubic feet.

Demo Code

#include <iostream>
using namespace std;
int get_values(int &length, int &width, int &depth);
int calc_cubic(int &length, int &width, int &depth, int &cubic);
int print_cubic(int &cubic);
int main()//from  w  w  w.java 2  s  . c om
{
   int length, width, depth, cubic;
   get_values(length, width, depth);
   calc_cubic(length, width, depth, cubic);
   print_cubic(cubic);
   return 0;
}
int get_values(int &length, int &width, int &depth)
{
   cout << "What is the pool's length? ";
   cin >> length;
   cout << "What is the pool's width? ";
   cin >> width;
   cout << "What is the pool's average depth? ";
   cin >> depth;
   return 0;
}
int calc_cubic(int &length, int &width, int &depth, int &cubic)
{
   cubic = (length) * (width) * (depth);
   return 0;
}
int print_cubic(int &cubic)
{
   cout << "\nThe pool has " << cubic << " cubic feet\n";
   return 0;
}

Result


Related Tutorials