Suppose you are given a vector x. Write first a pseudo-code or algorithm that would print out the sum of all the entries in x. You will probably want to use a some kind of for loop construction to achieve this. 1: for i = start : finish do 2: statements 3: end for Now use the start:increment:finish notation, and modify your procedure slightly, to print out the sum of the odd elements in the array (that is, the elements in entries 1, 3, 5, and so on). Implement and test your algorithm with an arbitrary array of real numbers using Python.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 11PE
icon
Related questions
Question

Suppose you are given a vector x. Write first a pseudo-code or algorithm that would print out the sum of all the entries in x. You will probably want to use a some kind of for loop construction to achieve this.

1: for i = start : finish do

2: statements

3: end for

Now use the start:increment:finish notation, and modify your procedure slightly, to print out the sum of the odd elements in the array (that is, the elements in entries 1, 3, 5, and so on). Implement and test your algorithm with an arbitrary array of real numbers using Python.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning