Answer to Question #70468 in C++ for SELBY MANYATSI
write program in c++ using for loops statements to print a circle of stars and diamond of stars
New
1
2017-10-10T15:34:07-0400
#include <iostream>
using namespace std;
const int N = 12;
int main()
{
int c, k, s = 1;
s = N - 1;
for (k = 1; k<=N; k++)
{
for (c = 1; c<=s; c++)
cout<<" ";
s--;
for (c = 1; c<= 2*k-1; c++)
cout<<"*";
cout<<"\n";
}
s = 1;
for (k = 1; k<= N - 1; k++)
{
for (c = 1; c<= s; c++)
cout<<" ";
s++;
for (c = 1 ; c<= 2*(N-k)-1; c++)
cout<<"*";
cout<<"\n";
}
return 0;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++
Comments
Leave a comment