Develop Pseudocode and Desk checking for the following programs. Your solutions should allow the user to provide the number of elements in each array and array should be initialised according to the user input. Proper functions should be used in each program to promote modularity.
1. Find the average of a list of numbers
2. Find the smallest value from a list of numbers
1.main
2.declare integer array A of size 20
3. Declare integer size, i=0
4. Output” Enter number of elements in array”
5. Input size
6. For i =0 to size-1, step size i =i+1
Input A[i]
7. Average= Call avg(A,size)
8. Smallest= call minimum(A,size)
9. Output “Average= “ Average
10. Output “smallest value =“ smallest
11. Stop main.
Pseudocode avg(int A[ ], int size)
1.Begin
2. Declare integer total=0,i =0
3. Declare float average
4. For i =0 to size-1, step size 1
total= total +A[i]
5. average= total/size
6. Return average
7. End
pseudocode: minimum ( int A[ ], int size)
1. Start
2. Declare integer min
3. Assign min= A[0]
4.For i =1 to size-1, step size 1
If A[i]< min
Assign min= A[i]
5. End loop
6. Return min
7.End.
Desk check:
enter number of elements in array:5
10
21
3
42
5
Average=16.2
Smallest=3
Get Answers For Free
Most questions answered within 1 hours.