i want to doa thing like if (input != anumber)
but what woudl i put meaning not a number 1-9999999999999999999999999999999999999999999999 (any number)
Printable View
i want to doa thing like if (input != anumber)
but what woudl i put meaning not a number 1-9999999999999999999999999999999999999999999999 (any number)
if ((input >= min) && (input <= max))
Is this what you're asking?
that will work but not exactly
well i need it to say if it doesnt equal a number
Quote:
well i need it to say if it doesnt equal a number
I'm not picking up what you're putting down. What exactly are you asking?Quote:
if (input != anumber)
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?Quote:
i think he means if they enter a character instead of a number
I think he's asking how to represent java's NaN (not a number). Kinda like 7/0 or something like that.
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
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.
that didnt work it if u accidnelty input a character it goes all crazy
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;
}
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..
if you stillahve puuullllleaaaaaase send it!
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
}