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: * * *
Step-by-step explanation:
Following is the description of program 
- Create a function problem2().
- Declared a variable "num" of "int" type .
- Read the input in "num" by the user .
- Iterating the for loop and set the width by using setw() and print the asterisk.
- In the main function calling the problem2().