Program to check whether a given number is even or odd using a function

Advertisements
Advertisements
Advertisements3
Advertisements4
Advertisements6
Advertisements66

 

#Write a code using a function to check whether a given number is even or odd

x= int(input("enter a number: "))
def evenorodd(x):
    if x == 0:
        print("0 is neither odd nor even ")
    elif x%2 == 0:
        print("Given number is even ")
    else :
        print("Given number is odd ")

evenorodd(x)


Author: Lakshmi Prasanna Ponnala

Completed M.Tech in Digital Electronics and Communication Systems.

Leave a Reply

error: Content is protected !!

Discover more from ece4uplp

Subscribe now to keep reading and get access to the full archive.

Continue reading