• 0

Problem Solving


Question

1. Write pseudocode to solve the following problem.

(i) Declare an array nums that can hold 100 real numbers.

(ii) Write pseudocode to load nums with 100 values, entered via the keyboard. Assume all data are valid.

(iii) Write pseudocode to prompt for an integer target. Search array nums for target. If found, print the location where target was found. Otherwise, print “Not found”.

(iv) Briefly explain how your response to 1 (ii) would change if the input data is stored in a file instead of being read via the keyboard. Note: No pseudocode is necessary. Only an explanation is need.

2. A file “input.dat” exists and is loaded with several positive integers. Each integer is separated by at least one space and the last value in the file is -1, which signifies the end of the data. Assume all data are valid.

Write pseudocode to read the values in the file and find and print the sum of all integers in the file that are greater than 50. For example, if the file contains

5 70 10 3 80 100 -1

 

you are only to find the sum of the integers 70, 80 and 100.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

We will not do homework/assignments for you

Try it yourself first, see how far you get, ask us some question, we will point you in the right direction, but will not give you the answer

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.