Once again another question.
I want to change the inner loop from "for loop" to "while loop".
I cannot figure out my errors.
error C2065: 'j' : undeclared identifier
error C1903: unable to recover from previous error(s); stopping compilation
So I am trying to convert this "for loop":
CODE
#include <iostream>
using namespace std;
int main()
{
int len;
cout << "Enter a number: ";
cin >> len;
for (int i = 0; i < len; i++)
{
for (int j = i+1; j < len; j++)
{
cout << ' ';
}
cout << "#\n";
}
}
into this (or what i have so far):
CODE
#include <iostream>
using namespace std;
int main()
{
int len;
cout << "Enter a number: ";
cin >> len;
for (int i = 0; i < len; i++)
{
while (j < len)
{
int j = i+1;
j++;
cout << ' ';
}
cout << "#\n";
}
}