Question
The pseudocode for finding the sum (total) of a set of floating point numbers stored in an array A, and finding the smallest value of
The pseudocode for finding the sum (total) of a set of floating point numbers stored in an array A, and finding the smallest value of all the data are given as below.
Pseudocode for Sum
Sum(A, N)
sum N
for I 1 to N
sum sum + A[I]
return sum
Pseudocode for smallest
Smallest(A, N)
smallest A[1]
for I 2 to N
if A[I] < smallest
smallest A[I]
return smallest
Write a C++ program will use two functions Sum and Smallest to find the sum and smallest of a set of floating point numbers. Main should declare and get inputs for the array and then call each of the two functions, to find the sum and the smallest values.
The Euclid algorithm for determining the GCD (greatest common divisor) of two integers x and y is described as below:
Euclid (a, b)
while b != 0
c a % b
a b
b c
return a
Write a C++ program with a function written based on the above algorithm. Now call this function suitably by sending two inputs a and b. Before calling the function Euclid, must check if a > b, if not first swap them using a swap function.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started