Prompts the user to enter a number N between 1 and 80. o If the number is not in
ID: 3804366 • Letter: P
Question
Prompts the user to enter a number N between 1 and 80. o If the number is not in the specified range, prompt the user to try again. o Repeat until an acceptable number is given. Print the following pattern, starting with 1 star: o Print 1 star. o On the next line, print 2 stars. o Continue this pattern so that the last line of output has N stars. Sample Run (Inputs will be shaded. Bold outputs must change depending on the input.) Enter a real number between 0 and 10: -7 is not in the specified range please try again Please USe CH languageExplanation / Answer
/* I have done the first question,second question is not the subpart of first question
please post this as a different question,Please do ask in case of any confusion,Thanks..!! */
#include <iostream>
using namespace std;
int main()
{ int input; //variable to store input
cout << "Enter a real number between 1 and 80:" << endl;
cin>>input;
/*asking the user to enter again*/
while(input<1 || input>80){
cout << input<<" is not in the specified range;please try again:" << endl;
cin>>input;
}
/* Printing stars */
for(int i=1;i<=input;i++){
for(int j=1;j<=i;j++)
cout<<"*";
cout<<" ";
}
return 0;
}
/*****OUTPUT*********
Enter a real number between 1 and 80:
81
81 is not in the specified range;please try again:
-9
-9 is not in the specified range;please try again:
3
*
**
***
/****OUTPUT****/
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.