Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem #2: 120 pts) Write a program that prompts the user to enter the size 'n' (ONLY positive) of an array 'a' and its integer

image text in transcribed

Problem #2: 120 pts) Write a program that prompts the user to enter the size 'n' (ONLY positive) of an array 'a' and its integer elements. The program should calculate and output the sum of ODD elements in EVEN positions (if any). For example, given the below array, 0 4 2 8 5 7 The sum is af0+a[ 41=3+7=10. The element a[2] is not added to the sum because the value is even Sample run 1 Enter the array size (only positive) : -5 No array Sample run 2 Enter the array size (only positive): 7 Enter a[01-7 Enter a 1) - 2 Enter a [2]- 5 Enter a [3]- 14 Enter a [4]- 13 Enter a [5) - 11 Enter a[6] - 18 The sum is 25 //hint the sum 13 a[0] +a[21ta141=7+5+13-25

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions