jiwonman
asked on
I am making a diamond by inputting the odd number between 1 to 10
I finished the code except making it like a diamond shape. any help?
#include <iostream>
using namespace std;
int main()
{
int oddnumb;
do
{
cout << "type your oddnumber";
cin >> oddnumb;
} while(oddnumb>=1 && oddnumb %2 != 1 &&oddnumb <10);
int star,numb;
for (star =1; star<=oddnumb ; star+=2) //for 1,3,5
{
for (numb = 1 ; numb <=star; numb++)
{
cout<<"*";
} cout << endl;
}
for(star = oddnumb-2; star>=1; star-=2)
{
for(numb = star; numb>=1; numb--)
{
cout << "*";
}
cout << endl;
}
system("pause");
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
May I ask why you gave a B grade ? That usually means that something was missing in the answer. If something is still not clear, then please ask about that, and I'll be happy to help you further :)
ASKER
I am sorry, it's my first time using this website. I didn't know what to click. I was working on different projects( trying to learn as many as I can, I am currently working on matrix multi one. it's really tough for me..). Anyways, the answer was A++. I'm sorry for that.
No problem ... I just wanted to make sure that you were helped ;)
ASKER