Write a program that reads in a number n and prints out asterisks(‘*’) in the shape of a
rectangle having n rows and 2*n columns. Thus for n=3 your program should print
******
******
******
#include <iostream>
int main() {
int n;
std::cout << "Enter number of asterisks:";
std::cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n*2; ++j) {
std::cout << "*";
}
if (i != n - 1) std::cout << "\n";
}
return 0;
}
Comments
*****Excellent work *****
Leave a comment