Hi I'm new to C++ and to here.
I have an assignment.
Make a rectangle using Functions.
Have the user imput the row size and column width.
It should look something like this (It's supposed to be a rectangle...hollow) :
**********
* *
* *
* *
**********
I'm only able to get this:
***********
***********
***********
***********
***********
here's my code ( I know it's something in my FOR loop) :
#include <iostream>
using namespace std;
//Function prototype
void displayStars (int, int);
int main ()
{
int row, column;
cout << "Enter the number of rows and columns: ";
cin >> row >> column;
while (column < 2 || column > 60 && row < 2 || row > 60)
{
cout << "Invalid values for rows and columns" <<endl;
cout << "Please enter values between 2 - 60: " ;
cin >> row >>column;
}
displayStars(row, column);
return 0;
}
//Definition of function displayStars
//This function displays a square made of astericks
void displayStars (int rows, int cols)
{
//Nested loop. The outer loop controls the rows
//and the inner loop controls the columns.
for (int across = 0; across < rows; across++)
{
for (int down = 0; down < cols; down++)
cout << "*";
cout <<endl;
}
}