Need a project done?

C++ Programming Developer

Search This Blog

Function to display solid square of asterisks


/*
Write a program by defining a function "Square" to display solid square of asterisks (insert space between asterisks) whose side is passed a integer parameter to the function. For Example, if side is 5, then Solid Square should be displayed as
shown below.
*/

#include <iostream>
using namespace std;



inline void Square (int);

int main()
{
int length;
cout<<"Length: "; cin>>length;
Square(length);

return 0;
}

//Function for Printing Square.
void Square (int length)
{
for (int row = 0; row<length; row++)
{
for (int column = 0; column < length; column++)
cout<<"* ";

cout<<endl;
}
}

No comments:

Post a Comment

"Don't let anyone ever make you feel like you don't deserve what you want."