Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Take the SI and PASS Mid-semester Survey!
- Take this survey at your leisure, but not during the session.
- This will help us leaders by providing anonymous feedback on the program!
- http://unf.co1.qualtrics.com/jfe/form/SV_8kREAxCL5NjPp66
- PROBLEM #1
- Construct a program that uses two nested for loops to print 10 lines of 10
- integers that shows the row and column position.
- The first loop represents the ROWS.
- The nested loop (second loop) represents each COLUMN in a row.
- The first number in the brackets is the row and the second is the column.
- 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]
- /*** SKELETON CODE ***/
- #include <stdio.h>
- #define ROWS 10
- #define COLS 10
- int main(void)
- {
- return 0;
- }//end main
- PROBLEM #2
- Analyze the program below. How might you use a break and continue statement to stop
- and prompt the user for a new input after 4 loops, and then skip the second else if?
- #include <stdio.h>
- int main(void)
- {
- int input = 5;
- int counter = 0;
- while(counter++ < 100) {
- printf("I am in loop #: %2d\n",counter);
- if(counter == 4){
- printf("Enter in a new input: ");
- scanf(" %d", &input);
- //I want to enter the next iteration of the loop here
- }
- else if(counter >= 10) {
- printf("I am breaking out of this.\n");
- //I want to exit the loop here
- }
- }
- return 0;
- }
- PROBLEM #3
- Write a program that will calculate the area of a square using
- a length input from the user.
- Compute the area using the pow() function in the <math.h> library.
- Print out the area of the square 2 decimal places to the right.
- PROBLEM #4
- Write a program that generates a random number using the rand() function.
- Run the program 2-3 times and observe the results.
- Afterwards, add the srand() call with the time() argument to add randomness to the numbers.
- You only need to call srand() once in the program before the rand() calls.
- PROBLEM #5
- Create a program that will generate a random set of numbers between 10 and 20, inclusively.
- Print the number to the screen a couple of times.
- PROBLEM #6
- Write a program that simulates flipping a coin for 1000 times
- and report the number of heads and tails you get.
- Use a for loop to control the amount of coin flips.
- Your heads and tails variables are used to KEEP TRACK of how many times heads or tails occurs.
- NOTE: use the random number generator.
Add Comment
Please, Sign In to add comment