C++ examples for Statement:for
Display a solid square of asterisks whose side is specified in integer parameter side.
#include <iostream> void displaySquare(int); int main(int argc, const char *argv[]) { int side;//www . j a va 2 s.c o m std::cout << "Enter side: "; std::cin >> side; displaySquare(side); return 0; } // displays a square of asterisks of size n void displaySquare(int n) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { std::cout << "*"; } std::cout << std::endl; } }