Amazon Prime




 
Tagged
  • Flow Chart
  •  

    Even Odd Checker

    Problem Statement

    1Problem Description :
    2Write Java Program to check whether a given integer is Even or Odd
    3
    4Example 1 :
    5
    6 Input : 27
    7 Output : Odd
    8 Explanation : 27 divide by 2 results remainder as 1.
    9
    10Example 2 :
    11
    12 Input : 36
    13 Output : Even
    14 Explanation : 36 divide by 2 results remainder as 0.

    Algorithm

    1Step 1 : Start
    2Step 2 : Read number "n"
    3Step 3 : rem = n % 2 (Initialize remainder as rem)
    4Step 4 : If rem = 0, print Even
    5Step 5 : Else print Odd.
    6Step 6 : End

    Flowchart

    Area of a Circle - Flowchart

    Code Implementation

    1. Java
    2. C

    1import java.util.Scanner;
    2
    3public class EvenOdd {
    4
    5 public static void main(String[] args) {
    6 Scanner sc = new Scanner(System.in);
    7 System.out.println("Enter Number :");
    8 int number = sc.nextInt();
    9
    10 int rem = number % 2 ;
    11 if (rem == 0) {
    12 System.out.printf("%d is Even\n", number);
    13 }else {
    14 System.out.printf("%d is Odd\n", number);
    15 }
    16 }
    17}

    Output 1:

    1Enter Number : 21
    221 is Odd
     

    Output 2:

    1Enter Number : 18
    218 is Even
     

  • Flow Chart
  •  
    ...