Q:

For each of the following, decide whether you would use a for loop, a while loop, a nested loop (and if so what kind, e.g. a for loop inside of another for loop, a while loop inside of a for loop, etc.), or no loop at all. DO NOT WRITE THE ACTUAL CODE

0

 For each of the following, decide whether you would use a for loop, a while loop, a nested loop (and if so what kind, e.g. a for loop inside of another for loop, a while loop inside of a for loop, etc.), or no loop at all. DO NOT WRITE THE ACTUAL CODE.

  1. sum the integers 1 through 50:
  2. add 3 to all numbers in a vector:
  3. prompt the user for a string, and keep doing this until the string that the user enters is a keyword in MATLAB:
  4. find the minimum in every column of a matrix:
  5. prompt the user for 5 numbers and find their sum:
  6. prompt the user for 10 numbers, find the average and also find how many of the numbers were greater than the average:
  7. generate a random integer n in the range from 10 to 20. Prompt the user for n positive numbers, error-checking to make sure you get n positive numbers (and just echo print each one):
  8. prompt the user for positive numbers until the user enters a negative number. Calculate and print the average of the positive numbers, or an error message if none are entered: 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

  •  sum the integers 1 through 50: No loop
  •  add 3 to all numbers in a vector: No loop
  •  prompt the user for a string, and keep doing this until the string that the user enters is a keyword in MATLAB: while loop
  •  find the minimum in every column of a matrix: No loop
  •  prompt the user for 5 numbers and find their sum: for loop
  •  prompt the user for 10 numbers, find the average and also find how many of the numbers were greater than the average: for loop
  •  generate a random integer n in the range from 10 to 20. Prompt the user for n positive numbers, error-checking to make sure you get n positive numbers (and just echo print each one): while loop in a for loop
  • prompt the user for positive numbers until the user enters a negative number. Calculate and print the average of the positivenumbers, or an error message if none are entered: while loop

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now