Answer:
Following is the program in C++ language
#include <iostream> // header file
#include <iomanip> // header file
using namespace std; // namespace std;
void problem2() // function definition
{
int num ; // variable declaration
cout << "Enter the Number: ";
cin >> num; // Read the input by user
cout << "Resulatant is:";
for(int k = 0; k <num; k++) // iterarting the loop
{
std::cout << std::setw(num); // set width
std::cout <<"*"; // print *
}
}
int main() // main function
{
problem2();// function calling
return 0;
}
Output:
Enter the Number: 3
Resulatant is: * * *
Explanation:
Following is the description of program