Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to check if number is even

if ( n % 2 == 0 ) {
	// n is even
}
else {
	//otherwise odd
}
Comment

check if a number is even or odd

// @Author: Subodh 
// 1 liner solution
(num & 1) ? cout << num << " is odd" : cout << num << " is even" << endl;
Comment

Even or odd number

/* Program to check whether the input integer number 
 * is even or odd using the modulus operator (%)
 */
#include<stdio.h>
int main()
{
   // This variable is to store the input number 
   int num;
 
   printf("Enter an integer: ");
   scanf("%d",&num);
 
   // Modulus (%) returns remainder
   if ( num%2 == 0 )
      printf("%d is an even number", num);
   else
      printf("%d is an odd number", num);
 
   return 0;
}
Comment

check whether number is even or odd

#check wheather a is odd or even
'''interactive mode
>>> 10%2
0....................False #(False==0)
>>> 5%2
1....................True  #(True==1)'''
#scriptive mode
a=int(input('enter:'))
if a%2:
    print("its odd")#solution gives true if 'a' value is even
else:
    print("its even")#solution gives false if 'a' value is odd 
print('hope it helped')
#output
#False
enter:100
its even
hope it helped
#even
enter:101
its odd
hope it helped
Comment

Finding Even and Odd Numbers

<?php
      $check1 = 3534656;
      $check2 = 3254577;
      if($check1%2 == 0) {
        echo "$check1 is Even number <br/>";
        
      } else {
        echo "$check1 is Odd number <br/>";
      }

      if($check2%2 == 0) {
        echo "$check2 is Even number";
      } else {
        echo "$check2 is Odd number";
      }
    ?>
Comment

check a number is odd or even

def is_even(num):
	return not bool(num % 2)
Comment

PREVIOUS NEXT
Code Example
Python :: threading in python 
Python :: iterrows pd 
Python :: insert a new row to numpy array in especific position 
Python :: pandas print column by index 
Python :: aws django bucket setting 
Python :: installing intel-numpy 
Python :: repeat a condition n times one by one python 
Python :: python dict add item 
Python :: making your own range function with step in python 
Python :: how to implement heap in python 
Python :: class chain methods python 
Python :: python dictionary delete based on value 
Python :: pass integer by reference in Python 
Python :: install python 3.4 mac terminal 
Python :: python collection 
Python :: dash authentication 
Python :: How To Remove Elements From a Set using pop() function in python 
Python :: keras.datasets no module 
Python :: how to round a number up in python 
Python :: requirements.txt dev python 
Python :: how to play audio in python using pygame 
Python :: how to repeat a row in pandas 
Python :: How determine if a number is even or odd using Modulo Operator 
Python :: numeric up down python tkinter 
Python :: circle python programe 
Python :: pydrive download by url 
Python :: python iteration 
Python :: program to demonstrate encapsulation in python 
Python :: display pil image on kivy canvas 
Python :: python random.sample 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =