C Programming For your fifth programming assignment you will
C++ Programming.. For your fifth programming assignment, you will write a program that will ask the user to enter a character and a number. If the number is even, the program should draw a hollow square composed of the character with the width the same as the number entered; if it\'s odd then it should draw a right triangle with the height the same as the number entered. Nested loops, good program structure, and indentation are required. USE ONLY \"WHILE/ELSE/IF LOOPS\" , NO \"FOR LOOPS\". Thanks.
Solution
#include <iostream>
 using namespace std;
int main()
 {
    char character;
    int number,row,col;
   
    cout<<\"\ Enter the character\";
    cin>>character;
   
    cout<<\"\ Enter the number\";
    cin>>number;
    cout<<endl;
   
   
    if(number%2 == 0) //number is even
    {
        row=1;
    while (row <= number)
    {
       col=1;
    while(col <= number)
    {
            if (row > 1 && row < number && col > 1 && col < number) //for row > 1 to number -1 and col > 1 and number -1 print space
                cout << \" \";
            else
            cout << character; //print character for first row,last row first column and last column
            col++;
        }
        cout << \"\ \";
        row++;
    }
   
    }
   
   
 else if(number%2 !=0) //number is odd
 {
    row=1;
    while(row <= number)
    {
       col=1;
       while(col<= row) //col increases with rows
       {
           cout<<character;
           col++;
       }
       row++;
       cout<< \"\ \";
      
    }
 }
   
    return 0;
 }
output:


