Canna

Saturday, 15 June 2019

Even or odd

  • Problem Description

    Somesh and sakthi played one game to find the number is even or not, for that they have designed one coding, using union concept
    track yourself by your code to challenge them for their inputs.

    Input Method

    Integer ranges from 1 to 999

    Output Method

    Print the number is even or not

    Mandatory:

    Use Structure Concept
  • Test Case 1

    Input (stdin)
    2
    
    
    Expected Output
    Even
  • Test Case 2

    Input (stdin)
    5
    
    
    Expected Output
    Odd
  • Program
  • #include <stdio.h>
    struct data
      {
      int a;
      }d;
    int main()
    {
    
      scanf("%d",&d.a);
      if(d.a%2==0)
      
      printf("Even");
      
        else
          printf("Odd");
         
      
      
        
    
     return 0;
    }

No comments:

Post a Comment

Note: only a member of this blog may post a comment.