Ask Question
1 November, 16:30

Write a main method that prompts the user for an integer between 1 & 20 (inclusive). If the user enters an invalid number, prompt for another one. When a valid number is entered, call activity with that number as a parameter.

+2
Answers (1)
  1. 1 November, 19:21
    0
    int main () {

    int num;

    cout<<"Enter the number"<
    cin>>num;

    if (num20)

    {

    while (num>20 || num<1) / /taking input if the number is not within range ...

    {

    cout<<"Enter the number again"<
    cin>>num;

    }

    activity (num); //calling activity with the num ...

    }

    return 0;

    }

    Explanation:

    Above written is the main function in which a prompting an integer between 1 and 20 if it is not within range then again taking input. Then after that calling activity with num as argument.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a main method that prompts the user for an integer between 1 & 20 (inclusive). If the user enters an invalid number, prompt for ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers