Using an inline function to calculate the volume - C++ Function

C++ examples for Function:Function Creation

Description

Using an inline function to calculate the volume

Demo Code

#include <iostream>

inline double cube(const double side) { 
   return side * side * side; 
}

int main(int argc, const char *argv[]) {
    double sideValue;

    std::cout << "Enter the side length of your cube: ";
    std::cin >> sideValue;/*from  w w w  . j a  va  2s. c om*/

    // calculate cube of sideValue and display result
    std::cout << "Volumen of cube with side " << sideValue << " is " << cube(sideValue) << std::endl;
    return 0;
}

Result


Related Tutorials