It is useful when designing functions to have functions which do one thing, only. For instance, if you have a function that calculates the perimeter of a square, it should calculate and return the value to the calling code. It probably shouldn't print the value.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
int perimetros(int largo) {
return 4 * largo;
}
int embado(int largo) {
return largo * largo;
}
int main() {
int lado;
std:: cin >> lado;
std::cout << perimetros(lado) << " " << embado(lado) << std::endl;
}