Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE HELP IN MATLAB Assume the variable NUMS is defined as a list of numbers. Write a code segment that utilizes a loop to total

image text in transcribed

PLEASE HELP IN MATLAB

Assume the variable NUMS is defined as a list of numbers. Write a code segment that utilizes a loop to total up all of the numbers in the list up to, but not including, the first positive number. Store the result in the variable NEGSUM.

% test cases % NUMS = [ -1, -4, -2, 1, 7, 9]; NEGSUM = -7; % NUMS = [ 1,-2,-3,-4]; NEGSUM = 0; % your code segment here %----------------------- % set the variable NEGSUM to be the sum of the all numbers in NUMS up to the first positive number 

Notes:

  • Your code must use a loop.
  • You may assume that there is always a positive number in the list
  • Your code must work for any valid list of numbers.
  • Do not include any test cases in the code you submit.
(version 885) Assume the varlable NUMS Is defined as a llst of numbers. Write a code segment that utilzes a loop to total up all of the numbers In the list up to, but not Including the first positive number. Store the result in the variable NEGSUM % test cases %MMS- [ -1, -4, -2, 1, 7, 9]; NEGSUM % NMS- [ 1,-2,-3,-4]i NEGSUM- @i -7; % your code segment here % sat the variable NEGSUM to be the sum f tha all numbers in NUMS up to the first positive number Notes: Your code must use a loop. .You may assume that there is always a positive number in the list .Your code must work for any valld llst of numbers Do not include any test cases in the code you submit

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_2

Step: 3

blur-text-image_3

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

Object Oriented Databases Prentice Hall International Series In Computer Science

Authors: John G. Hughes

1st Edition

0136298745, 978-0136298748

More Books

Students also viewed these Databases questions