a guest Nov 22nd, 2019 109 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Problem#1
  2. Write a C program that populates a 10 x 10 square 2d array of integers. Use a nested
  3. for loop to fill the array with the value of the row times the column. Compose a
  4. function that receives the array as a parameter and prints the contents to screen
  5. using nested for loops. Your output should resemble the output shown below. It’s
  6. the 10 times table. Hint: Test the main function before adding another to minimize
  7. time spent troubleshooting.
  8. Problem#2
  9. Write a program that declares a single dimensional array of 10 integers. Create a
  10. function that uses a for loop to load the array with random integers from 0 to 20.
  11. Add a second function using a for loop to print the contents to the screen separated
  12. by spaces or commas. Your functions will need to take the array and the size as
  13. parameters as a minimum. You may add more parameters as you wish. Run your
  14. program a few times. Are the numbers random?
  15. //View my solution, yours may be different, that’s okay.
  16. Problem #3
  17. Using the previous program or my solution, Add a prompt to the user to enter in one
  18. of the displayed values. Declare a new local declared variable to store the entered
  19. value. This will be a search term. Create a linear/sequential search function to
  20. search the array for the entered value. Your function will return the index indicating
  21. the location of the element and the program will display the location(index) to the
  22. user.
  23. Your function will need to return an integer, take an integer array, a size variable,
  24. and a search term variable as parameters. Make sure to declare a variable in the
  25. calling function (main) to store the returned value. NOTE: your solution may not
  26. deal with duplicates and I am not asking you to check.
  27. Problem #4
  28. Create a program that declares an array of 10 integers. Initialize the array with
  29. numbers in ascending order. They can be 0 – 9 or randomly picked by you. Create a
  30. new function called binarySearch. This function will take the same parameters but
  31. instead of visiting each element in the array it will use the binary search method.
  32. You may look at the example in the Zybook 11.4.1 for guidance. What this function
  33. does is find a new middle to the array after each search, halving the size of the array
  34. to search with each failed search. This search method relies on the array being
  35. searched being in order. If it is not in order the element being searched will be
  36. missed.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand