Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For this problem using C programming, you will generate a random number, make a

ID: 3816319 • Letter: F

Question

For this problem using C programming, you will generate a random number, make a guess until you guess correctly. Each time the statistics will be written to a file. For one set of games you will make a guess until you guess correctly. For the second set you will receive an indication of whether you guess was too high or two low. There will be one file ‘straight.txt’ with one line with each count, and another file ‘hints.txt’ with one line with each count. After both sets of games are finished, the program will read straight.txt and print the number of games, total guesses and average with labels. Then it will read hints.txt and print the same information with a label.You will use rand to get a number n. Then the user types in a guess, if the guess is out of range it is ignored, else if is correct a count of guesses is printed to the screen and a file.Each incorrect guess is printed in the correct postion of a line.If the straight version just the guess is printed. If the hints version the printed number is negative if too low and positive if two high.

There will be four constants, you must use these everywhere in your code
#define MAX 16
#define GAMES 8
#define STRAIGHT "straight.txt"
#define HINTS "hints.txt"

Game 1 should look like this

game 2 should look like this

Straignt 16 Game 1 10 11 12 13 14 15 16 Correct in 16 tries Game 2 10 11 12 13 14 15

Explanation / Answer

#include <stdio.h>
int random_number(int min_num, int max_num);
int main(void)
{
printf("Min : 1 Max : 30 %d ", random_number(0,5));
printf("Min : 100 Max : 1000 %d ",random_number(50,100));
return 0;
}
int random_number(int min_num, int max_num)
{
int result = 0, low_num = 0, hi_num = 0;
if (min_num < max_num)
{
low_num = min_num;
hi_num = max_num + 1;
} else {
low_num = max_num + 1;
hi_num = min_num;
}
srand(time(NULL));
result = (rand() % (hi_num - low_num)) + low_num;
return result;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote