Added a 'Note' part. (#32776)

The 'Note' part describes how we can check for odd even with the help of & operator.
This commit is contained in:
Papun Charan
2019-06-25 23:34:53 +05:30
committed by Randell Dawson
parent 447b8f50fc
commit b07fac01b2

View File

@ -254,6 +254,27 @@ evaluated first.
- Assignment `= += -= *= /= %= >>= <<= &= ^= |=` - Assignment `= += -= *= /= %= >>= <<= &= ^= |=`
- Comma `,` - Comma `,`
## Note:
We can use & operator for checking whether a given number is even or odd more quickly than regular way.
### Example
```C
#include<stdio.h>
int main()
{
int a=25;
if(a&1)
printf("Odd");
else
printf("Even");
return 0;
}
```
## Output
```
-> Odd
```
The value of (a & 1) will be a non zero element only when a is odd, and 0 if it is even.
## 7. Conditional Operators ## 7. Conditional Operators
## Syntax ## Syntax