63 064
Assignments Done
99,1%
Successfully Done
In July 2018

Answer to Question #52416 in C++ for reem

Question #52416
prompt the user to enter an integer number from 1 to 10 if the number is less than 3 you should output a message telling that the number lies between 1 and 3 if the number lies between 1 and 7, you should output a message telling that the number lies between 1 and 7 , if the number entered is more than 7 you should output a message telling that the number is lies between 7 and 10 . how to write this program
Expert's answer
#include <iostream>
#include <cstdlib>

using namespace std;

int main() {

    int number;

    cout<<"Enter the number from 1 to 10 : ";

    cin>>number;

    if (cin.fail() || number < 1 || number > 10)  {
        cout<<"wrong input\n";
        system&#40;"pause"&#41;;
        return 0;
    }

    if (number > 0 && number < 4) {
        cout<<"number lies between 1 and 3\n";
        system&#40;"pause"&#41;;
        return 0;
    }

    if (number > 3 && number < 8) {
        cout<<"number lies between 4 and 7\n";
        system&#40;"pause"&#41;;
        return 0;
    }

    if (number > 7) {
        cout<<"number lies between 7 and 10\n";
        system&#40;"pause"&#41;;
        return 0;
    }

    return 0;
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions