Hello,
I have a school assignment that i really need help with. I am supposed to create an X shape with asterisks using for loops. I am terrible at for loops so i was wondering if you guys could help me out a little in figuring out the best solutions. I'd really appreciate it.
This is the code i have so far. I am able to get one diagonal side but not the other.
#include <iostream>
using namespace std;
int main()
{
int number;
cout<< "Enter a number: ";
cin>> number;
while (number< 2 || number% 2 == 0)
{
cout << "Invalid response. Enter an odd number greater than or equal to 2:";
cin>> number;
}
for( int lineNum=0; lineNum<number; lineNum++)
{
cout <<"*";
for (int i=0; i<number-lineNum; i++)
cout<<" ";
cout<<endl;
for (int x= 0; x<= lineNum; x++)
cout<< " ";
}
cout<< endl;
system( "Pause");
return 0;
}
thanks again