Question

c++ program that displays asterisk shapes of square, oval, arrow and diamond that looks like the...

c++ program that displays asterisk shapes of square, oval, arrow and diamond that looks like the picture.c++ program that displays asterisk shapes of squar

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int i=0, j=0, NUM=3,r=0, s=0, iNUM=3, x, h, k, b;
for(int co=0; co<4; co++)
{
cout <<endl<<endl;
for(int row=0; row<4; row++)
{
if((co==0 || co==4-1) || (row==0) || (row ==4-1))
{
cout << " * ";
}
else cout<<" ";
}
}
/*Oblong*/   
cout<<"\n\n";
for(x=1;x<=6;x++)
{
if(x==1 || x==6)
{
for(h=1;h<=7;h++)
{
if(h==3 || h==4 || h==5)
cout<<"*";
else
cout<<" ";
}
cout<<endl;
}
else
if(x==2||x==5)
{
for(k=1;k<=7;k++)
{
if(k==2||k==6)
cout<<"*";
else
cout<<" ";
}
cout<<endl;
}
else
{
for(b=1;b<=7;b++)
{
if(b==1||b==7)
cout<<"*";
else
cout<<" ";
}
cout<<endl;
}
}
/*arrow*/
int count = 0;
cout<<"\n";
for (int width = 0; width <= 3; width++)
{
for (int alignLeft = width; alignLeft <= 2; alignLeft++)
{
cout << " ";
}
for (int sp = 1; sp < count; sp++)
{
cout << "*";
}
cout << endl;
count += 2;
}
cout<<" * \n";
cout<<" * \n";
cout<<" * \n";
cout<<" * \n";
/*diamond*/
cout<<"\n";
for(r=-iNUM; r<=iNUM; r++)
{
for(s=-iNUM; s<=iNUM; s++)
{
if( abs(r)+abs(s)==iNUM)
{
cout<<"*"; }
else { cout<<" ";}
}
cout<<endl;
}
getch();
return 0;
}

Add a comment
Know the answer?
Add Answer to:
c++ program that displays asterisk shapes of square, oval, arrow and diamond that looks like the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT