Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Trying to output this: \"Please enter a positive integer: 10 10 9 8 7 6 5 4 3 2

ID: 669432 • Letter: T

Question

Trying to output this:

"Please enter a positive integer: 10

10

9

8

7

6

5

4

3

2

1

0

****

1

2

3

4

5

6

7

8

9

10"

Trying to output this using recursion. This is what I have so far:

#include <stdio.h>
void recursive_down_to_zero();
int main(int argc, char * argv[]);
       {
           int input1;
           input1 = 10
           printf("Please enter a positive integer: %d", input1);
          
           recursive_down_to_zero(input1-1);
           return 0;
       }
void recursive_down_to_zero()
{
   if (input1 = 0)
       printf("**** ")
       recursive_down_to_zero(input1 + 1)
       return 0;
}

Explanation / Answer

#include <stdio.h>
void recursive_down_to_zero();
int main(int argc, char * argv[]);
       {
           int input1;
           input1 = 10
           printf("Please enter a positive integer: %d", input1);
          

int decreasing = 1;
           recursive_down_to_zero(input1, decreasing,max);
           return 0;
       }
void recursive_down_to_zero(int val, int order, int max)
{

if( val > max) return;

printf("%d ", val);
if (val == 0)
{ printf("**** "); order = 0;}

if( order == 1)
recursive_down_to_zero(val-1,1);
else
recursive_down_to_zero(val+1,0);

return ;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote