473,396 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do I say not equal to more than one number?

I am trying to say if( my variable is not equal to 1 or 2)

I would write

if(variable != 1 ) but I do not know how to say or 2 in programming language?
Feb 27 '10 #1

✓ answered by donbock

You don't want to say "or". You want
(variable != 1) and (variable != 2)
So the question is, what is the operator for logical-and?

5 13987
donbock
2,426 Expert 2GB
You don't want to say "or". You want
(variable != 1) and (variable != 2)
So the question is, what is the operator for logical-and?
Feb 27 '10 #2
im using gcc for mac , so how would i format that to say and?
Feb 28 '10 #3
Banfa
9,065 Expert Mod 8TB
Look in an C/C++ book or online reference for the operators or just google "C++ operators".

All the operators are a basic part of the language and you should know about them if you are going to program in C/C++
Feb 28 '10 #4
See if u want to write
1> if given variable is either not equal to 1 or 2 you need to code:
if((variable !=1)||(variable!=2)) // ' | '(just above enter key ) :is called as pipeline operator and is logical equivalent of " or "

2>if given variable is not eqal to both 1 & 2 :
if((variable !=1)&&(variable!=2)) // ' & ' :is and operator
if this is not what u r looking for please ask questions
Feb 28 '10 #5
donbock
2,426 Expert 2GB
@DEAbhishekBUG
This expression is not very useful -- it is always true.
Feb 28 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: PG | last post by:
When deleting a row from the database, that id is now missing. So what I'm trying to do is update in a loop (maybe an sql loop if there is one) of all of the id numbers - sort of like renaming...
12
by: jose luis fernandez diaz | last post by:
Hi, My OS is: cronos:jdiaz:tmp>uname -a HP-UX cronos B.11.11 U 9000/800 820960681 unlimited-user license I compile in 64-bits mode the program below:
39
by: Antoon Pardon | last post by:
I was wondering how people would feel if the cmp function and the __cmp__ method would be a bit more generalised. The problem now is that the cmp protocol has no way to indicate two objects are...
1
by: ToChina | last post by:
Is it possible to write a restriction on a simple type which states that the number of sub-elements of an element must be the same as its attribute value? Hmm, perhaps this example would make...
16
by: alakesh.haloi | last post by:
Hi All Is there a limit on the number of register variables that can be declared and initialized in a C program on a particular hardware platform? If you define more number of register variables...
0
by: roh | last post by:
Hello Friends, We are developing a web based application using DB2 UDB Ver 8.1 FixPack7 and Web Sphere Application Server 6.0. We are facing following issue: When number of users logged into...
2
by: wisten | last post by:
This program is to create a simple application to generate random number between 1 and 50. additional: when the user click on the Start button, a random number will be displayed every 300ms.Display...
2
by: ckrows | last post by:
i am new to the VBA world. I am using a option group to give the user checkboxes. 1 = Blue 2 = Red 3 = Black 4 = Green However using the option group it only stores the values as numbers.
3
by: DEAbhishekBUG | last post by:
sir i am a student and i always want to learn more i replied for the question -how-do-i-say-not-equal-more-than-one-number my reply was 1> if given variable is either not equal to 1 or 2 you need...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.