Question
I am trying to create this program for c++ and I cannot get it to work. Receiving many errors when I run it. Can I
I am trying to create this program for c++ and I cannot get it to work. Receiving many errors when I run it. Can I please get some home here is the requirement and my code
. Define an array with a maximum of 20 integer values and fill the array with numbers input from the keyboard or assigned by the program. Write a function named split() that reads the array and places all zeros or positive numbers in an array named positive and all negative numbers in an array named negative. Finally, have your program call a void return-type function named displayArray() that displays the values in both the positive and negative arrays. This means your program must invoke the displayArray() function twice, once to display the positive array and once to display the negative array. Remember to declare your displayArray() function with a function prototype.
#include "stdafx.h"
#include
#include
#include
#include
using namespace std;
void split(int []);
int main()
{
int number[ 20 ] = { -110, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100,
-10. - 20, -30, -40, -50, -60, -70, -80, -90, -100 };
split(number);
cin.get();
cin.ignore();
return 0;
}
void split(int number[])
{
int i, j = 0, k = 0;
int positive[20] = { 0 }, negative[20] = { 0 };
for ( i = 0; i < 20; i++)
{
if (number[ i ]<=0)
{
positive[j] = number[i];
j++;
}
else
{
negative[k] = number[i];
k++
}
}
cout << "The Positive numbers are " << endl;
for (i = 0; i < positive[i] != '\0'; i++)
{
cout << positive[i] << " ";
}
cout << endl;
cout << " The Negative numbers are " << endl;
for (i = 0; negative[i] != '\0';; i++)
{
cout << negative[i] << " ";
}
{
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started