Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that asks the user to enter an integer between 1 and 15. If the

ID: 3567332 • Letter: W

Question

Write a program that asks the user to enter an integer between 1 and 15. If the number entered is
outside that range, your program should print out an error message and re-prompt for another
number.
Once the user enters a number in the correct range, your program will print out two patterns of
asterisks that look like the following. Note that the number provided by the user is equal to the
height of the pattern.
Let us say that the input value was 5. Then please print the following two patterns:

and 8

Write a program that asks the user to enter an integer between 1 and 15. If the number entered is outside that range, your program should print out an error message and re-prompt for another number. Once the user enters a number in the correct range, your program will print out two patterns of asterisks that look like the following. Note that the number provided by the user is equal to the height of the pattern. Let us say that the input value was 5. Then please print the following two patterns: and 8

Explanation / Answer

#include <iostream>
using namespace std;


int main()
{
int n;
  
cout<<"Enter between 1 and 15: ";
cin>>n;
cout<<" ";
  
while(!(n>=1 && n<=15))
{
cout<<"Wrong input !!Reenter data: ";
cin>>n;
}
cout<<" ";
  
for(int i=n; i>=1 ;i--)
{
for(int j=i; j>=1; j--)
{
cout<<"*";
}
cout<<" ";
}
  
cout<<" ";
  
for(int i=n; i>=1 ;i--)
{
for(int x = i; x < n; x++)
{
cout<<" ";
}
for(int j=i; j>=1; j--)
{
cout<<"*";
}
cout<<" ";
}
  
  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote