write a program to input a number and check whether the number is even or odd
Answers
Answered by
1
Answer:
#include <stdio.h>
int main() {
int num;
printf("Enter an integer: ");
scanf("%d", &num);
// true if num is perfectly divisible by 2
if(num % 2 == 0)
printf("%d is even.", num);
else
printf("%d is odd.", num);
return 0;
}
Answered by
0
import java.util.Scanner;
class OddEvenCheck
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n;
System.out.print("Type a Number :");
n=sc.nextInt();
if(n%2==0)
{
System.out.println("Entered Number is Even");
else
System.out.println("Entered Number is Odd");
}
}
}
Similar questions