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

What is wrong with my program? /* This program enters a number between 4 and 20

ID: 3617235 • Letter: W

Question

What is wrong with my program?
/* This program enters a number between 4 and 20 and uses the "*"character to represent the number and display the number atthe end of the line.*/




#include<iostream>
using namespace std;

int main()
{
    int num;
    do
    {
        cout << "Pleaseenter a number between 4 and 20" << endl;
        cin >> num;
           if(num < 4 || num > 20)
              cout << "Number must be between 4 and 20" << endl;
      }while(num<4||num>20);
  
    for(short i=0;i<num;i++)
           cout << '*';
cout << num;
    do
    {
        cout << "Pleaseenter a number between 4 and 20" << endl;
        cin >> num;
           if(num < 4 || num > 20)
              cout << "Number must be between 4 and 20" << endl;
      }while(num<4||num>20);
  
    for(short i=0;i<num;i++)
           cout << '*';
cout << num;
do
    {
        cout << "Pleaseenter a number between 4 and 20" << endl;
        cin >> num;
           if(num < 4 || num > 20)
              cout << "Number must be between 4 and 20" << endl;
      }while(num<4||num>20);
  
    for(short i=0;i<num;i++)
           cout << '*';
cout << num;
do
    {
        cout << "Pleaseenter a number between 4 and 20" << endl;
        cin >> num;
           if(num < 4 || num > 20)
              cout << "Number must be between 4 and 20" << endl;
      }while(num<4||num>20);
  
    for(short i=0;i<num;i++)
           cout << '*';
cout << num;
do
    {
        cout << "Pleaseenter a number between 4 and 20" << endl;
        cin >> num;
           if(num < 4 || num > 20)
              cout << "Number must be between 4 and 20" << endl;
      }while(num<4||num>20);
  
    for(short i=0;i<num;i++)
           cout << '*';
cout << num;
do
    {
        cout << "Pleaseenter a number between 4 and 20" << endl;
        cin >> num;
           if(num < 4 || num > 20)
              cout << "Number must be between 4 and 20" << endl;
      }while(num<4||num>20);
  
    for(short i=0;i<num;i++)
           cout << '*';
cout << num;


    system("pause");
  
return 0;
}

Explanation / Answer

please rate - thanks never duplicate code unless necessary--you have the identical code6 times. you were missing an endl /* This program enters a number between 4 and 20 and uses the "*"character to represent the number and display the number atthe end of the line.*/ #include using namespace std; int main() {     int num,i;     for(i=0;i
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