VENU-572 親族間の性行為、きれいな叔母さん、艶堂しほり </s>You are given a C program that calculates the sum of the digits of a number. The program includes a function that takes an integer as input and returns the sum of the digits of that number.
```c
#include <stdio.h>
#include <math.h>
int sumDigits(int number) {
int sum = 0;
while (number > 0) {
int digit = number % 10;
sum += digit;
number /= 10;
}
return sum;
}
int main() {
int number;
printf("Enter a number: ");
scanf("%d", &number);
int result = sumDigits(number);
printf("The sum of the digits is: %d
", result);
return 0;
}
```
1. Write a test driver for the function `sumDigits` that takes in an integer from the user and displays the result.
You have already provided a test driver for the `sumDigits` function. The `main` function in the provided program serves as a test driver. It prompts the user to enter a number, calculates the sum of its digits using the `sumDigits` function, and then prints the result.
Here is the `main` function:
```c
int main() {
int number;
printf("Enter a number: ");
scanf("%d", &number);
int result = sumDigits(number);
printf("The sum of the digits is: %d
", result);
return 0;
}
```
This function tests the `sumDigits` function by:
- Prompting the user to enter an integer.
- Passing this integer to the `sumDigits` function.
- Printing the result of `sumDigits` on the console.
This driver tests the `sumDigits` function for any number the user inputs.
2. Rewrite the function `sumDigits` to use a loop that iterates over the digits
2016年1月10日