From b07fac01b2d52a641003afb8c850a6b33c30870c Mon Sep 17 00:00:00 2001 From: Papun Charan <42942897+richard937@users.noreply.github.com> Date: Tue, 25 Jun 2019 23:34:53 +0530 Subject: [PATCH] Added a 'Note' part. (#32776) The 'Note' part describes how we can check for odd even with the help of & operator. --- guide/english/c/operators/index.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/guide/english/c/operators/index.md b/guide/english/c/operators/index.md index 53651a8490..1edcfbad3b 100644 --- a/guide/english/c/operators/index.md +++ b/guide/english/c/operators/index.md @@ -254,6 +254,27 @@ evaluated first. - Assignment `= += -= *= /= %= >>= <<= &= ^= |=` - Comma `,` +## Note: +We can use & operator for checking whether a given number is even or odd more quickly than regular way. +### Example +```C +#include +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 ## Syntax