Consider 3 , 5 , 8 , 10 , 5 , 2 , 1 , 7 , 3 , 13  as an input to the list of n integers. Dry run the following piece of code and find out the answer.   procedure func(a1, a2, . . . , an: integers) k:= 0 for i:= 1 to n if i  is odd then k: = k+ai+i return k

Mathematics For Machine Technology
8th Edition
ISBN:9781337798310
Author:Peterson, John.
Publisher:Peterson, John.
Chapter85: Hexadecimal Numeration System
Section: Chapter Questions
Problem 30A
icon
Related questions
Question

Consider 3 , 5 , 8 , 10 , 5 , 2 , 1 , 7 , 3 , 13  as an input to the list of n integers. Dry run the following piece of code and find out the answer.

 

procedure func(a1, a2, . . . , an: integers)

k:= 0

for i:= 1 to n

if i  is odd then k: = k+ai+i

return k

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Searching and Sorting
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, advanced-math and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Mathematics For Machine Technology
Mathematics For Machine Technology
Advanced Math
ISBN:
9781337798310
Author:
Peterson, John.
Publisher:
Cengage Learning,
Algebra & Trigonometry with Analytic Geometry
Algebra & Trigonometry with Analytic Geometry
Algebra
ISBN:
9781133382119
Author:
Swokowski
Publisher:
Cengage
Algebra: Structure And Method, Book 1
Algebra: Structure And Method, Book 1
Algebra
ISBN:
9780395977224
Author:
Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. Cole
Publisher:
McDougal Littell
College Algebra
College Algebra
Algebra
ISBN:
9781337282291
Author:
Ron Larson
Publisher:
Cengage Learning
Holt Mcdougal Larson Pre-algebra: Student Edition…
Holt Mcdougal Larson Pre-algebra: Student Edition…
Algebra
ISBN:
9780547587776
Author:
HOLT MCDOUGAL
Publisher:
HOLT MCDOUGAL
College Algebra (MindTap Course List)
College Algebra (MindTap Course List)
Algebra
ISBN:
9781305652231
Author:
R. David Gustafson, Jeff Hughes
Publisher:
Cengage Learning