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

how do i input the formula using c language...plz help me with the random number

ID: 3747914 • Letter: H

Question

how do i input the formula using c language...plz help me with the random number and the last part where the user can repeat

2. Strength. The robots will attempt to lift several heavy objects 3. Combat effectiveness. The robots will battle against 100 humans and then receive a score based on the number of victories. Create three functions (one for each phase). 1. float calculate_speed (float finish_line_distance) 2. int calculate_strength() 3. int calculate_combat(float speed, int strength) calculate_speed() should take the distance to the finish line as an argument, perform the speed test from the first workshop and return the robot's speed. calculate_strength () should prompt the user to input a whole number between O and 100 (representing the number of objects the robot could successfully lift) and return that number. calculate_combat() should simulate 100 rounds of combat against human opponents. A robot's percentage chances of winning in combat can be calculated using the following formula: strength Min speed, 50) + 100 X 50 The "Min" portion of the formula can be read as "either speed or 50, whichever is smallest" The +10 portion of the formula should be calculated as a random number from -10 to 10 The function should use random number generation for the combat and return a whole number representing the total number of victories. The program should also include a main() function that calls each of the above three functions in sequence At the end of the main function, the user should be asked if they would like to repeat the simulation again. The program should not end under any circumstances other than the user choosing not to repeat.

Explanation / Answer

As per question  ..plz help me with the random number and the last part where the user can repeat

I am providing answer


// C program for generating a
// random number in a given range.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
  
// Generates and prints 'count' random
// numbers in range [lower, upper].
int printRandoms(int lower, int upper)
{
int num = (rand() %
(upper - lower + 1)) + lower;
return num;
}
  
// Driver code
int main()
{
//for calculate random number between 10 and -10
//assign lowr to -10 and upper to 10
int lower = -10, upper = 10, count = 1;
  
// Use current time as  
// seed for random generator
srand(time(0));
  
//to repeat code take input from user and use while
int a=1;
while(a!=0){
  
int rndNUm=printRandoms(lower, upper);
printf(" Random number generated is :%d",rndNUm);
printf(" For exit press 0 ");
scanf("%d",&a);
}
  
return 0;
}