68 382
Assignments Done
98,5%
Successfully Done
In November 2018

Answer to Question #70468 in C++ for SELBY MANYATSI

Question #70468
write program in c++ using for loops statements to print a circle of stars and diamond of stars
New
Expert's answer
#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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions