Question #260531

Create a program that will Ask a user to enter a number. If the number is between 0 and 4, write the word blue. If the number is between 5 and 10, write the word red. if the number is between 11 and 14, write the word green. If it is any other number, write that it is not a correct color option.If else statement in C++

Expert's answer

#include <bits/stdc++.h>
using namespace std;
int main()
{
    cout << "Enter a number:\n";
    int n;
    cin >> n;
    if (n>=0 && n<=4) cout << "Blue\n";
    else if (n>=5 && n<=10) cout << "Red\n";
    else if (n>=11 && n<=14) cout << "Green\n";
    else cout << "That is not a correct color\n";   
}
LATEST TUTORIALS
APPROVED BY CLIENTS