Even or Odd number

Write a program to find a number if even or odd with out using conditional operator and if-else?

Showing Answers 1 - 6 of 6 Answers

anurag

  • Apr 9th, 2015
 

Using swich

Code
  1. scanf("%d""num is even""num is odd""wrong choice");

  2.  

  3. }

  Was this answer useful?  Yes

urvashi

  • Apr 10th, 2015
 

Code
  1. scanf("%d""even""odd");

  Was this answer useful?  Yes

Baiju M P

  • Jul 10th, 2015
 

Code
  1. scanf("%d""odd""even");

  Was this answer useful?  Yes

Alejandro Visedo

  • Mar 5th, 2016
 

Using only bit operators.

Code
  1. span style="color: #ff0000;">"even", "odd""%d""%d is %s

  2. ", num, text[index]);

  Was this answer useful?  Yes

debakanta rout

  • Apr 2nd, 2016
 

int num
scanf("%d",&nnum);
char *p[2]={"even","odd"};
printf("%d" is %s",num, p[num&1]);

Markandayan

  • Sep 11th, 2017
 

By using bitwise opertor
(even_number & 1) -> 0
(odd_number & 1) -> 1

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions