+ 1

How we use boolean expression in if condition for a alphabet and special character ?

For example I want to write a code that cheek a variable if it is even or odd and if the input variable isn't a number the I want output to be invalid. What should I do to make it right?

2nd Jun 2022, 3:34 PM
John
John - avatar
4 Réponses
+ 4
In general the numbers can be tested for even and odd with modulo 2 (x%2 == 0) division. For another things will be better to know in which language you want to code.
2nd Jun 2022, 3:55 PM
JaScript
JaScript - avatar
+ 2
John , please modify your post by naming the programming language
2nd Jun 2022, 6:36 PM
Lothar
Lothar - avatar
+ 1
next().charAt(0);
3rd Jun 2022, 1:56 PM
Khushi Singh
0
You can use an if-else statement, a switch statement or catching exceptions. The way you implement it syntactically is very dependent on the language though.
2nd Jun 2022, 4:04 PM
Justice
Justice - avatar