Error in my code

Hello,
Can anyone tell me what I do wrong?

I want this program to check for a number
If it is between 1-20 it must print the "IT IS LIKE I SAID" msg.
If not it shoudl print "NOT IN THAT SPACE"
If however the number is 1 or 20 it should print "BORDERLINE NUMBER"

What am I doing wrong?It always evaluates on the "BORDERLINE NUMBER" condition...

I know it must be a very very stupid mistake...

----------------------------------------------
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>

using namespace std;

main()
{
      long int x;
      cout<<"Please enter a number. I will see if the number is between 1-20 and tell you."<<endl;
      cin>>x;
      if ((x>=1)&&(x<=20)) 
      {
                          if ((x=1)||(x=20))
                          {
                          cout<<"Borderline number."<<endl;
                          }
                          else
                          cout<<"It is like I said..."<<endl;
                          
      }
                          
      else 
      {
           cout<<"Not in that space."<<endl;
      }
      cout<<"Thank you." ;    
      return 0;
      }
      
Last edited on
closed account (z05DSL3A)
Line 12 the =s should be ==s
= is for assignment, == is for comparing for equality.
main() is also incorrect, it has to be int main().
To check equality in c/c++ you should use == (double equal signs) as the single = sign is for assignment.

On line 12 use if ( (x == 1) || (x == 20) )
I KNEW IT WAS STUPID!!!!!
Thanks guys...
Topic archived. No new replies allowed.