i need help please...i ask, to make a program that accepts a positive integers and displays all odd number between 1 to the integer entered (inclusive) accept the integer in main() and use a recursive function to identify and display the odd numbers.

tnx..salie

It seems you are just laying down a flat-out request for us to code you something. Not gonna happen. Post the code you have come up with so far and where you got stuck, etc. and I'll try helping from there.

I'll give you a small start:

(assume number is an integer variable)

A number is odd when the modulus is not equal to 0.
For example:

if( number % 2 )
{
   // The number is odd
}
else
{
  // The number is even
}

BTW, What are you going to do when the user enters a negative number?

if( number < 0 )
{
    // Negative number entered
    // Put your code to handle negative numbers here
}

A quick resume:

- Accept positive integers:

Declare an array, and use cin within a for-loop to fill it up with user entered numbers (also add a check to see whether the number is positive or not, before adding it to the array (see my example))

- Use a recursive function to identify and display the odd numbers:

From your main() function, you call the recursive function, inside the body of that function, you check whether the element is an even or an odd number (see my example), when the number is an odd number, you display it on the screen, you keep calling that function from itself until you've processed each element in the array.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.