Thread: does not equal

1. does not equal

i want to doa thing like if (input != anumber)

but what woudl i put meaning not a number 1-9999999999999999999999999999999999999999999999 (any number)

2. if ((input >= min) && (input <= max))

Is this what you're asking?

3. that will work but not exactly

4. well i need it to say if it doesnt equal a number

5. well i need it to say if it doesnt equal a number
if (input != anumber)
I'm not picking up what you're putting down. What exactly are you asking?

6. i think he means if they enter a character instead of a number

7. i think he means if they enter a character instead of a number
Are you asking... If I ask for a numerical input, how do I verify it's a number and not a letter?

8. I think he's asking how to represent java's NaN (not a number). Kinda like 7/0 or something like that.

9. i want it to see if it does not equal a number meaning not a number is a-z !@@##%%^%%^*(#\$@# that kind of stuff. a numbe being like math. you know

10. You're asking...If I ask for input, how do I verify it's a letter and not a number?

if ( (((int)intput) < 176) && (((int)input) > 185) )

where input is a char. That's a lot of parenthesis.

There might be a better way though.

11. that didnt work it if u accidnelty input a character it goes all crazy

12. Is this you're looking for?

----------
code :
----------

#include <iostream.h>

typedef unsigned long int lint;

int main()
{
lint input;
lint num = 100;
lint max = 4294967295;

cout<<"Give a number : "<<endl;
cin>>input;

if ( ((input >= 1) && (input <= max)) && (input != num) )
cout<<"Ok";
else
cout<<"Not Ok";

return 0;
}

13. hmm

i dont know if there's a better way of doing this, but..

here's how i would do it :-

get the input to an array...

check out through each element of the array and see
if there's atleast 'one' element that is other than
0,1,2,3,4,5,6,7,8,9 (and) '.' (if you're also considering
floating points) .. and '-' ... and so on... (note that
- and . can't repeat in the array)

(i've done this before... let me check if i still have it )
meanwhile, try it with these clues..

14. if you stillahve puuullllleaaaaaase send it!

15. Searching around on MSDN i found this function:

Code:
```#include <ctype.h>

//..

if( isdigit(input) != 0 )
{
// input is a digit
} else {
// input is a character
}```

Popular pages Recent additions