Computer Science, asked by shrutisingh782006, 3 months ago

write a program to input a number and check whether the number is even or odd​

Answers

Answered by vishaldattav
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 AestheticAmaira
0

\large{\underline{\underline{\maltese{\pink{\pmb{\sf{ \; Question \; :- }}}}}}}

\sf{{write \:a  \:  }{program \: to \: input \: a \: number \: and \: check \: whether \: it \: is \: odd \: or \: even.}}

\large{\underline{\underline{\maltese{\pink{\pmb{\sf{ \; Source \: code \; :- }}}}}}}

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