Write a pseudo code algorithm which asks a user to enter a number between 5 and 20. If they enter a number outside this range, the program asks them repeatedly to re-enter the number until they enter a valid number.
If a valid number n is entered, the program asks the user to enter n temperatures (all integer values), then calculates and outputs the average temperature.

Respuesta :

do
ask for input
while input less that 5  or more than  20
set   total to 0
loop   input  times
get temp
add temp to  total
end loop
output    total/input


Following are the pseudo-code and program to the given question:

Pseudo-code steps:

  • start.
  • Declaring integer variable.
  • Input number.
  • Defining a loop that checks the input number is in between 5 to 20.
  • If the number is not in range input number.
  • Outside the loop, print the matched value.
  • stop.

Program:

#include <iostream>//header file

using namespace std;

int main()//main method

{

int n;//defining an integer variable

cout <<"Enter a number in the range of (5-20): " ;//print message

cin>>n;//input number

while(n<=5||n>=15)//defining loop that check the input value range

{

cout<<"Enter a number in the range of (5-20): ";//print message

cin>>n;//input number

}

cout<<"Your number is: "<<n<<endl;//print number

return 0;

}

Output:

Please find the attached file.

Learn more:

brainly.com/question/1319833

Ver imagen codiepienagoya
ACCESS MORE