### Recursive function & arrays

I am facing a simple problem, I couldn't figure out the right condition when it comes to check the value of index 0

Here is the question
 Write a recursive function named SeparateNumbers which takes as parameters an array of integers and the array size. The function should print out all the positive numbers and then all the negative numbers. The function should NOT print any of the zeros in the array. The prototype for the function is: void SeparateNumbers (int array[], int size); Example If the array contains the following values before calling the function SeparateNumbers: 1 0 4 -3 5 2 -7 2 The function SeparateNumbers should display the following output: 2 2 5 4 1 -3 -7

My solution
 ``123456789101112131415161718192021222324252627282930313233343536`` ``````#include using namespace std; void SeparateNumbers (int Array[], int size); int main() { int size, Arr[100]; cout<<"Enter the size of the array: "; cin>>size; cout<<"Enter the number in the array:-"<>Arr[i]; SeparateNumbers (Arr, size); cout<= 0) { if(Array[size-1] > 0) { cout<
You can write the condition the following way

 ``12345678910111213141516`` ``````void SeparateNumbers (int Array[], int size) { if( size > 0 ) { if(Array[size-1] > 0) { cout<

But in any case the result will be incorrect because the order of elements will be broken.
Consider for example array

{ 1, 2 )

It will be printed as

2, 1
Topic archived. No new replies allowed.