Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Pastebin for KAHOOT quiz answers: https://pastebin.com/dWChiCgq
- PROBLEM #1: Nested Loop Review
- Construct a program that uses two nested for loops to produce 10 lines of 10
- integers that shows the row and column position. The first loop represents the rows
- and the nested loop represents each column in a row. The first number is the row
- and the second is the column position. Your output should look something like this:
- [0,0] [0,1] [0,2] [0,3] [0,4] [0,5] [0,6] [0,7] [0,8] [0,9]
- [1,0] [1,1] [1,2] [1,3] [1,4] [1,5] [1,6] [1,7] [1,8] [1,9]
- [2,0] [2,1] [2,2] [2,3] [2,4] [2,5] [2,6] [2,7] [2,8] [2,9]
- [3,0] [3,1] [3,2] [3,3] [3,4] [3,5] [3,6] [3,7] [3,8] [3,9]
- [4,0] [4,1] [4,2] [4,3] [4,4] [4,5] [4,6] [4,7] [4,8] [4,9]
- [5,0] [5,1] [5,2] [5,3] [5,4] [5,5] [5,6] [5,7] [5,8] [5,9]
- [6,0] [6,1] [6,2] [6,3] [6,4] [6,5] [6,6] [6,7] [6,8] [6,9]
- [7,0] [7,1] [7,2] [7,3] [7,4] [7,5] [7,6] [7,7] [7,8] [7,9]
- [8,0] [8,1] [8,2] [8,3] [8,4] [8,5] [8,6] [8,7] [8,8] [8,9]
- [9,0] [9,1] [9,2] [9,3] [9,4] [9,5] [9,6] [9,7] [9,8] [9,9]
- PROBLEM #2: Calculating Area
- Write a program that prompts the user to enter in a value for the
- base of a square. Compute the area using the pow() function in the
- math.h library. Print out the area of the square with a minimum
- width of 8 and precision of 2 decimal places to the right.
- NOTE TO Repl.it users... note the compiler commands in the Console window
- uses -lm for the math linker. When executing your code on the Osprey server,
- you will have to use -lm in your gcc command if you use math functions.
- PROBLEM #2.5: Calculating Area of Circle
- Similar to problem #2, write a program that calculates area. This time,
- prompt the user for the diameter of a circle, and calculate the area of
- the circle.
- PROBLEM #3: Random Number Generator
- Write a program that generates a random number and prints it to the screen.
- Run the program 2-3 times and observe the results.
- Now add the srand() call with the time(NULL) argument to add
- randomness to the numbers. YOU ONLY NEED TO CALL srand() ONCE in the program
- before the rand() calls.
- (Not required to complete this problem) If you want to know more on WHY random numbers need a seed, here is a link:
- https://stats.stackexchange.com/questions/354373/what-exactly-is-a-seed-in-a-random-number-generator
- Fair warning, there is some HEAVY math involved.
- PROBLEM #4: Random Number Generator Continued
- Create a program that will generate a random set of numbers between 10 and
- 20 inclusively. Print the number(s) to the screen to confirm the range works.
- HERE IS A GUIDE TO MAKING A RANGE:
- yourRandomNumber = rand() % (max_number + 1 - minimum_number) + minimum_number
- PROBLEM #5: Coin Flipping and Probability
- Write a program that simulates flipping a coin 1000 times
- and report the AMOUNT OF TIMES it hit heads or tails. Use a for
- loop to control the random number generation and two variables
- to store the heads vs tails counts.
- Challenge: How could you cheat to make the heads have a 2/3 probability?
Advertisement
Add Comment
Please, Sign In to add comment