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

Program 2: Write a program that graphically depicts an integer\'s magnitude by u

ID: 3738899 • Letter: P

Question

Program 2: Write a program that graphically depicts an integer's magnitude by using asterisk, creating a histogram. Hint: The inner loop handles the printing of the asterisk and the outer loop handles exciting until zero is entered. Make sure you don't accept negative numbers. Sample run: Enter a positive integer (0 to quit): 5 Enter a positive integer (0 to quit): 8 Enter a positive integer (0 to quit): -5 Enter a positive integer (0 to quit): -10 Enter a positive integer (0 to quit): 15 Enter a positive integer (0 to quit): o Good Bye! Submit a copy of the program (15 points) and sample output for at least 4-5 numbers, including invalid data (5 points). Program 3: Write a program to display an upside down right triangle. Yu should ask the user to provide you with the height. Sample Run: Enter a number between 5 and 50: 10

Explanation / Answer

#include <iostream>

using namespace std;

int main()
{
int n;
cout<<"Enter a positive integer(0 to quit): "<<endl;
cin >> n;
while(n!=0){
if(n>0) {
for(int i=1;i<=n;i++){
cout<<"*";
}
cout<<endl;
}
cout<<"Enter a positive integer(0 to quit): "<<endl;
cin >> n;
}
cout<<"Good Bye!"<<endl;
return 0;
}

Output:

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