Menu

[Solved] C Programing Please Modify Code Use Loop Arrays Include Int Generaterandom Void Checklower Q37274274

C programing– Please modify my code. Do not use loop orarrays.

Program Set 2 (15 goints) Write a program that allow a user to guess a number generated by the computer between 1 to 100. For

#include <stdio.h>
int generateRandom();
void checkLowerOrHigher(int , int );

int main()
{

srand(time(0));
int num,n,count= 0;

num = generateRandom();

while(1)
{
count++;

printf(“nTake a guess: “);
scanf(“%d”,&n);

if(num == n)
{
printf(“nCongratulations, you got it!”);
printf(“nYou took %d tries “,count);

break;
}

else
checkLowerOrHigher(num,n);
}
return 0;
}

int generateRandom()
{
return rand() % 100 + 1;
}

void checkLowerOrHigher(int a, int b){
if(a<b)
printf(“nLower…”);
else
printf(“nHigher…”);
}

Program Set 2 (15 goints) Write a program that allow a user to guess a number generated by the computer between 1 to 100. For example, the computer generated a number 25, the user guess 50, the program will print a message that say”Lower User then guess again and enters 45. Program will prit·Lower,’ User then enters 15, program will print ‘Higher.. User guesses again and enters 25. Until the user match the number. You will have to use functions for this program, no global variables are allowed. Draw a structure chart to show all your functions and how they communicate with up and 1. 2. down arrows 3. No loops and arrays allowed Sample test run Guess the Computer Number Game Computer: I have a number in mind, guess my number Take a guess 60 Lower.. Take a guess: 30 Lower… Take a guess: 10 Higher… Take a guess: 15 Higher…” Take a guess: 17 Congratulations, you got it You took 5 tries. Show transcribed image text Program Set 2 (15 goints) Write a program that allow a user to guess a number generated by the computer between 1 to 100. For example, the computer generated a number 25, the user guess 50, the program will print a message that say”Lower User then guess again and enters 45. Program will prit·Lower,’ User then enters 15, program will print ‘Higher.. User guesses again and enters 25. Until the user match the number. You will have to use functions for this program, no global variables are allowed. Draw a structure chart to show all your functions and how they communicate with up and 1. 2. down arrows 3. No loops and arrays allowed Sample test run Guess the Computer Number Game Computer: I have a number in mind, guess my number Take a guess 60 Lower.. Take a guess: 30 Lower… Take a guess: 10 Higher… Take a guess: 15 Higher…” Take a guess: 17 Congratulations, you got it You took 5 tries.

Expert Answer


Answer to C programing– Please modify my code. Do not use loop or arrays. #include int generateRandom(); void checkLowerOrHigher(… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *