(Square of Asterisks) Write a function that displays at the left margin of the screen a solid square of asterisks whose side is specified in integer parameter side.
For example, if side is 4, the function displays the following:
****
****
****
****
Solution:
****
****
****
****
Solution:
#include <iostream> using std::cout; using std::cin; using std::endl; void square ( int ); int side; int main() { cout << "Enter side: "; cin >> side; square( side ); return 0; } //square function void square( int side ) { for( int i = 1; i <= side; i++ ) { for( int j = 1; j <= side; j++) { cout << "*"; } cout << endl; } }
Post A Comment:
0 comments: