0

What is error in even/odd program??

num = int(input ("enter any number:")) if (num%2)==0: print("number is even") else: print("number is odd") when I execute this code, it shows syntax error..

11th Sep 2017, 8:48 PM
Himakshi
3 odpowiedzi
+ 2
#Program: Odd Even Number num = int(input("Enter a number: ")) if (num % 2) == 0: print("{0} is Even".format(num)) else: print("{0} is Odd".format(num)) try this you will get your output
11th Sep 2017, 9:04 PM
MsJ
MsJ - avatar
0
what language are you using bruh ? as I assume you use Java or C , Scanner scanner = new Scanner(System. in); int number = scanner.nextInt(); if(number % 2 == 0){ //even here }else if(number % 2 == 1){ //odd here } VisualBasic : try Dim number as Integer = CInt( InputBox("Enter Number" , "OddEven" , 0) ) if number mod 2 = 0 then MessageBox.Show("Even") if number mod 2 = 1 then MessageBox.Show("Odd") catch ex as exception MessageBox.Show("something wrong with input") end try something like that..
11th Sep 2017, 9:45 PM
Mikhael Anthony
Mikhael Anthony - avatar
12th Sep 2017, 6:51 AM
Himakshi