Это часть домашнего задания, в котором пользователь вводит пять целых, и оно проходит через несколько функций, получая сумму, среднее значение, sqrt и пару других вещей.Вот код:
#include <stdio.h>
#include <math.h>
// needs to be declared in order to work
int functionPrint(int sum, int root);
//sum function, takes all the ints from main and sums it up
int functionSum(int one, int two, int three, int four, int five) {
int sum = one + two + three + four + five;
// sends the sum to the print function
sum = functionPrint(sum, sum);
}
//sqrt function, will take all numbers and square root them
int functionSqrt(int one, int two, int three, int four, int five) {
int root = sqrt(three);
// sends the sqrt numbers to print
root = functionPrint(root, root);
}
int functionPrint(int sum, int root) {
printf("Sum: %d\n", sum);
printf("Square Root: %d\n", root);
}
//main function, all values to be worked are created here and sent to the other functions
int main() {
int sumMain, one, two, three, four, five;
printf("Enter five numbers separated by spaces: ");
scanf("%d%d%d%d%d", &one, &two, &three, &four, &five);
sumMain = functionSum(one, two, three, four, five);
}
В настоящее время предполагается распечатать только сумму и sqrt из int трех (я включу другие целые числа, когда я это исправлю).functionPrint()
начинается со строки 21, а functionSqrt()
начинается со строки 15. Но, как я уже сказал, он печатает только сумму.Я предполагаю, что существует какая-то переменная, которая должна быть перезаписана, или что-то в этом роде.Но опять же, я не эксперт.
Любая помощь будет оценена