write a program to request two integer number,x and y. If x falls within the range of -2 and 7, y is either 5 or 10, then the program will display ""within range". Otherwise the program displays "out of range".

Help yes, do it for you no. Please show some proof that you've made an honest attempt to do this homework problem on your own.

#include <iostream>
using namespace std;

main()

{
int x;
int y;

cout<<"Enter an integer number : "<<x;
cout<<"Enter an integer number : "<<y;


if((x<7 && x>-2)&&(y=5 || y=10))
  {
    cout<<"within range"<<endl;
}

if (!(x<7 && x>-2)&&(y=5 || y=10))
{
    cout<<"out of range"<<endl;
}

i use codeblock software.. n got error. jus show me in c++ if u cant do codeblock. il convert it. sry im kind of new here ><

Two issues:

  1. You never populate x and y. You need to input those values using cin.
  2. The = operator is for assignment. When comparing values, use the == operator.

Compare and contrast:

#include <iostream>

using namespace std;

int main()
{
    int x;
    int y;

    cout << "Enter an integer number : ";
    cin >> x;

    cout << "Enter an integer number : ";
    cin >> y;

    if ((x<7 && x>-2)&&(y == 5 || y == 10))
    {
        cout << "within range" << endl;
    }

    if (!(x<7 && x>-2)&&(y == 5 || y == 10))
    {
        cout << "out of range" << endl;
    }
}

thx alot.. its function, il post more here :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.