-2

So Im Having Problems Making My Recursion Program to work. This Is My Code...

#include<iostream>
#include<fstream>
#include<string>
#include<windows.h>
#include<ctime>

using namespace std;

int i;
bool end = false;
int changer = -1;
int recursion(int num1)
{
    if(num1 = 0)
    {
    return 0;
    }
for(i = 1; i <= num1; i++)
    {
    cout << "*";
    }
cout << endl;
recursion(num1 - 1);
    }

int main()
{
int number;
cout << "Input Star Number...\n";
cout << "\t Input: ";
cin >> number;
recursion(number);
return 0;
}

The Output I Want. If I Input 4...

4 3 2 1

3 2 1

2 1

1

The OutPut I get

If I Input 4

Press Any Key.

I Got Nothing To Output. Please Help. Thank You.

(Sorry For Bad Grammer)

Note: Pretend There Is not A Space In Between The Numbers... Stock Over Flow Just Wont Line Line It Up The Way I Want.

Kara
  • 6,115
  • 16
  • 50
  • 57
  • For starters, change your if condition in your `recursion` function to be `num1 == 0`. Also, what did you want to do with the variable `end` as I do not see you use it anywyere. – Anil Dec 04 '14 at 19:22
  • Possible duplicate of [What is a debugger and how can it help me diagnose problems?](https://stackoverflow.com/questions/25385173/what-is-a-debugger-and-how-can-it-help-me-diagnose-problems) – Raedwald Feb 16 '18 at 17:24

1 Answers1

1

The problem is
if(num1 = 0)
It should be
if(num1 == 0)