can someone help me please! i want to write a C++ program which can show this as an out put:
****
***
**
*
*
**
***
****
this wat i hv done nd it shows no output:
#include <iostream>
using namespace std;
void DisplayLine(int n, int nDepth)
{ int i;
for(i = 4; i < n; i++)
cout << "*";
cout << endl;
if(n <= nDepth)
return ;
DisplayLine( n+1, nDepth);
for(i = 0; i < n; i--)
cout << "*";
cout << endl;
return ;
}
int main(void)
{
int nDepth= 4;
int n = 4;
cout << endl << endl;
DisplayLine(0, nDepth);
system("pause");
return 0;
}
Well in your code you are setting n in DisplayLine(...) to 0 from the call in main(). So the code inside your two for(...) loops isn't called.
Anyway, I supplied you some very simple code that does what you asked for!