Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ JUST DO NUMBER 4 DO NOT USE RECURSIVE (no void) For this problem, we wish to

ID: 3886950 • Letter: C

Question

C++ JUST DO NUMBER 4 DO NOT USE RECURSIVE (no void) For this problem, we wish to draw a number of shapes, using "character graphics". For each part of the problem, your program should input all parameters from the keyboard (after prompting the user). Moreover, the program should ensure that inputs are legal for the shape in question. Do not worry about the case where the parameters are too big to be displayed properly in the xterm. Draw a w-wide h-high rectangular frame, using asterisks. Ex (w=5, h=4): ***** * * * * ***** Draw the triangle constituting the northwestern half of a square, given the side length. Ex (side=5): ***** **** *** ** * Similar to 2, but for the southeastern half. Similar to 2, but excluding the top k rows (so, side and k are the inputs). Given a radius, draw a circle with that radius. Hint: Recall that a circle of radius r is defined as the set of points (x,y) where x2+y2

Explanation / Answer

#include<iostream>
using namespace std;
void rectangle(int w,int h)
{//method to print rectangle without recursion
   int i,j;
for(i=0;i<w;i++)
{
           cout<<"*";
       }
       cout<<" ";
      
   for(i=1;i<w-1;i++)
{
           cout<<"*";
           for(j=1;j<w-1;j++)
           {
               cout<<" ";  
           }
           cout<<"* ";
       }  
      
   for(i=0;i<w;i++)
{
           cout<<"*";
       }
       cout<<" ";  
  
}
//printing triangles..
void northwest_triangle(int n)
{
   int i,j;
   for(i=0;i<n;i++)
   {
       for(j=i;j<n;j++)
       {
           cout<<"*";
           }
           cout<<" ";  
   }
  
}

void southeast_triangle(int n)
{
       int i,j;
   for(i=0;i<n;i++)
   {
       for(j=0;j<n-i;j++)
       cout<<" ";
       for(j=0;j<i;j++)
       {
           cout<<"*";
           }
           cout<<" ";  
   }
  
}
//testing
int main()
{
   rectangle(5,4);
   cout<<" ";
   northwest_triangle(5);
   southeast_triangle(5);
  
   return 0;
}

output:-

*****
* *
* *
* *
*****


*****
****
***
**
*

*
**
***
****


Process exited normally.
Press any key to continue . . .

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote