Creating a new function in my program


I was given a project to complete, it is as follows:

A manufacturer wishes to determine the cost of producing an open-top cylindrical container. The surface area of the container is the sum of the area of the circular base plus the area of the outside (base circumference * height of container). Write a program that takes the radius of the base, the height of the container, the cost per square centimeter of material, and the number of containers to be produced. Calculate and report the cost of each container and the total cost of producing all the containers. Instructions to the user AND calculation of surface area MUST be in custom and separate functions.

How do I go about creating the separate and custom functions for this? Thank you.

This is not a job for an Arduino the program should be writen to run on a PC or as a phone app. For the rest look up “function”.


As a simple exercise, but maybe not as a productive commercial system, this could of course be achieved on an Arduino with a few statements. It is a bit of simple geometry, some statements, some simple maths, two functions, and some Serial.print() statements.

How about looking into Reference: Function Declaration?