Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a short program in which you will copy values out of one array and into another based on whether the values are positive,

image text in transcribed
image text in transcribed
image text in transcribed
This is a short program in which you will copy values out of one array and into another based on whether the values are positive, negative, or zero. A template program has been provided for you; to complete this assignment you will fill out the center portion. The template program declares and fills out an array called source. It will be filled with either a fixed set of values or random values, depending on how the symbolic constant RAND_ARR is set. The fixed set of values is provided so you can write your program using known, good values with consistent results. When you are ready, switch the value of RAND_ARR to 1 so that it fills with random values. Whichever array you use, your job is to write the code that copies the values out of the source array and into two new arrays: Copy the value into the pos array if the value is positive. Copy it into the neg array if the value is negative. Ignore the value (don't copy it) if the value is zero. The remainder of the template program will display the contents of the pos array. You will need to provide the code to display the neg array, as well. Functions? For this program, it is not necessary to break apart the program into functions. You can, if you wish, but the emphasis is on practicing to copy arrays. What to Turn In As usual, upload your C file here. Template and Help On most browsers, you will see some tabs below. The first tab contains the template code which you can copy and paste into your Cloud 9 editor. The other tabs contains some help in case you get stuck and need a little push to get started. Template Code Help: Count positive and negative Help: Cory into pos array #include #include #include // Change this constant to 1 to fill source array // with random values. #define RAND_ARRO #define SRC_SIZE 10 int main() { // Declare source array int source (SRC_SIZE]; // Fill array with random values or constant values if (RAND_ARR == 1) { // Seed random number generator srandom(time(NULL)); // Fill array with random values for (int i = 0; i

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

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

Write the difference between sexual and asexual reproduction.

Answered: 1 week ago

Question

What your favourite topic in mathematics?

Answered: 1 week ago

Question

Briefly describe vegetative reproduction in plants.

Answered: 1 week ago