Question: Function 1 is named getRandom. The function has integerr types, min and max. It generates and return a random number between min and max inclusive.

Function 1 is named getRandom. The function has integerr types, min and max. It generates and return a random number between min and max inclusive.

Function 2 is named getSummation. The function has one parameter of integer type, sum. It calculates and return the summation from 1 to num inclusive. That is, when you generate a random number from the above getRandom function, have the function sum up the number. For example, if your random number is 6, then the function will do 1 + 2 + 3 + 4 + 5 +6.

Function 3 is named printFactors. The function has one parameter of integer type, num. It prints the list of all factors of num, and return nothing.

The last function is the main function. It asks the user to enter the min and max, checks if the two numbers are valid. The numbers are valid when both numbers are positive and min is not greater than max. o If the numbers are not valid, then print a message.

Otherwise, o get a random number num between min and max using function getRandom, then o get the summation of num by calling function getSummation and print the summation, and finally o print all factors of num by calling function printFactors. Only use techniques discussed in class. Do not use goto statement, recursion, or global variables

I have completed the code, but I have encountered several problems:

1. When I run the code, it returns 2 random numbers.

2. getSummation does not calculate the sum properly.

3. printFactors does not calculate the factors of getRandom properly.

I am looking for help with these 3 things. Thank you!

Here is my code:

#include #include #include

void getRandom(int min, int max) { int number = (rand() % ( max - min + 1)) - min; printf("%d ", number); } void getSummation(int sum) { int Summation = 0; for(int a = 1; a <= sum; a++) { Summation += a; return Summation; } } void printFactor(int num) { int min, max; int number; num = number; for(num = 1; num <= number; num++) { if(number % num == 0) { printf("%d ", number); } } printf(" The Factors are: %d %d ", number, num); return; }

int main(void) { int min = 2; int max = 36; int a; int sum; int num; int number; srand(time(0)); printf("Please enter the min and max: "); scanf("%d %d", &min, &max); for(min = 0; min < 0; min++) { printf("I'm sorry, the numbers are negative. That is invalid. Please enter the numbers again: "); scanf("%d %d", &min, &max); } if(min > max) { printf("I'm sorry, that is not valid. Please enter the numbers again: "); scanf("%d %d", &min, &max); } else { printf("That is valid, you have guessed the numbers. Random Number is : %d %d", min, max); } getRandom(min, max); getSummation(a); printf("Summation is: %d ", sum); printFactor(num); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!