Hey you all. Does any of you know how to solve the code below to make a diamond pattern output? I just need help on the 'if' condition.Thanks in advance!
#include<iostream>
#include<cmath>
using namespace std;
int main()
{int x, y;
for (x=1;x<=5;x=x+1)
{
for (y=1;y<=5;y=y+1)
{
if(((abs(x-3)<y)&&(x+3>y)))
{
cout<<"*";
}
else
{
cout<<" ";
}
}
cout<<endl;
}
return 0;
}
Output (without the dashes):
--*
-***
*****
-***
--*
Thank you very much for that, but Im sorry i forgot mention that i cannot replace or add more than 2 variables. My instructor said the rules are to not change the 'for' operations, to add more variables and to solve only the 'if' condition.