Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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). You can print that value to the screen so that you check to make sure it compiles and works; then remove or comment out that print statement and continue to the next step. That square root value will be used as the radius of a circle. Your program will use a random number generator (RNG) to check if a randomly generated point falls within the circle with that radius and center at (0,0). Both values of the point (x,y) will be randomly generated. Dont forget to seed the random number generator first. Both times that rand() is called, the general formula 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 +(radius + 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 run, 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 correct range, comment out the line of code where it 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.

image text in transcribed

CPSC 1111 Lab Home l lab6,0df CSecure https://www.cs.clemson.edu/course/cpsc111/S18Labs/lab6.pdf Enter a 3 digit number: 100 C-2 1) 12, 10) 8. 10) -13.-8) 4) 81) -15, -9) 71) If your output matches what is shown above, you can continue with the rest of the program. You'll need the foemula f determinng if a point falls within a circle -you ean ogle this if you need to. Lising an if-else statement inside that loop that goes 10 times, print to the user whether that point lies insade, on the circumferenee of, or outside the cirele. Your finished output should lock like the following Enter 3 digit number : 100 [ -2, 1> i inside the circle with radiu8 10 [ 12, 10) i outside the circle with radiu 10 [ e, 10) 1 outside the circle with radiu5 10 [ 1e -3) is inside the circle with rdius 10 -6,-14) is outside the circle with radius 10 (-13,-8 outaide the circle with radius 10 [ s, 4> is inside the circle with rdiu 10 Br 1> is inside th circle with rdiua 10 -15, -9 is autside the circle with radius 10 7, 1> is inside the circle with radius 10 Turn In Work Before turning in your assignment, make sure you have followed all of the instructions stated in this assignment and any additional instructions given by your lab instructorfs).Always test, test, and retest that your program compiles and runs successfully on our Unix machines before submitting it. Show your TA that you complesed the assignment. Then submit your lab6.c program using the handin page checkzhe handin page ahat your submission worked. You can go to your twcket to see what is mere. If your program does no compile on cur Unix machines or your assignment was not subenitted on time, then you will receive a grade of zero for this assignment. Otherwise, points for this lab assignment will be eamed hased on the follewing 1024 PM E /212018 Type here to search

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Fundamentals Study Guide

Authors: Dr. Sergio Pisano

1st Edition

B09K1WW84J, 979-8985115307

More Books

Students also viewed these Databases questions

Question

5. How we can improve our listening skills?

Answered: 1 week ago