Question: C program help. Write a program called lab6.c which will prompt the user to enter a three digit number on the keyboard. Your program will
Write a program called lab6.c which will prompt the user to enter a three digit number on the keyboard. Your program will find the square root of the number using the sqrt function from the math library (make it also an integer value) Yon can print that valuc to the screen so that you check to make sure it compiles and works; then remove or comment out that print statement and continc to the next stap t square root value will be used as the radius of a circle. will use a random number gencrator (RNG) to check ifa randomly generated point falls within the circle with that radius and center at (0.0). Both values ofthe point (x y) will be randomly generated. Don't forget to seed the random number generator first. Both times that rand() is called, the gcneral frmula will be: (rand { % (total number of values within the range)) + (beginning value of the range } The range of values should be within -(radius+5) and +Hradius+5). The total number of values within the range will be an expression based on that range. Put this much into a loop that goes 10 times (except for seeding the RNG-this only needs to be done once before the loop) and show the (x.y) values each time. Compile and un, and verify by inspection that both the x and y values of each of the 10 points fall within the correct range, Run it several times and you will see a different set of random (x.y) values each time it is run. Once you feel confident that your random (x.y) values are within the corect range,comment out the line of code where i is seeded, and then recompile and run again. The output on the following page shows what you should get when entering 100 as your 3-digit input number with an un-seeded RNG. Enter a 3 digit number: 100 (-2, 1 12, 10) 8, 10) 1, -3) (-6, -14 5, 4 1) (7,1 If your output matches what is shown above, you can continue with the rest of the program. You'l need the formula for determining if a point falls within a circle-you can Google this if you need to. Using an if-else statement inside that loop that goes 10 times, print to the user whether that point lies inside, on the circum ference of, oe outside the circle. Your finished output should look like the following: Enter a 3 digit number: 100 -2, 1) is inside the circle with radius 10 12, 10) is outside the circle with radius 10 8, 10) is outside the circle with radius 10 1, -3) is inside the circle with radius 10 -6,-14) is outside the circle with radius 10 (-13, -8) is outside the cirele with radius 10 ( 5, 4) is inside the circle with radius 10 8, 1 is inside the cirele with radius 10 -15,-9) is outside the circle with radius 10 7, 1) is inside the circle with radius 10
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
