I am trying to get my for loops to output a diamond given user specific max and min, Even inputs are not allowed. Any ideas would be appreciated. Practice isn’t going as smooth as I thought this would be.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int rows, count;
cout<<"What is the width of the diamond (3 to 21, odd values only): ";
cin>>rows;
//Error checking
if(rows < 1 || rows > 25)
{
cout<<"Invalid. please enter an odd number from 1 to 25: ";
cin>>rows;
}
//Ascending
for (count = 1; count < rows; count += 1)
{
for (int rows = 0; rows < count; rows ++)
cout<<"*";
cout<<endl;
}
//Descending
for (count; count > 0; count -= 1)
{
for (int rows = 0; rows < count; rows ++)
cout<<"*";
cout<<endl;
}
cin.get();
cin.get();
return 0;
}
This performs the first half of the objective-: