Ask Question
4 December, 23:27

Write a main method that prompts the user for an integer between 1 & 10 (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.

+1
Answers (1)
  1. 5 December, 00:33
    0
    int main () {

    int n;

    cout<<"Enter the integer n"<
    cin>>n;

    if (n10)

    {

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

    {

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

    }

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

    }

    return 0;

    }

    Explanation:

    Above written is the main function in which a prompting an integer between 1 and 10 if it is not within range then again taking input. Then after that calling activity with n as argument.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a main method that prompts the user for an integer between 1 & 10 (inclusive). If the user enters an invalid number, prompt for ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers