Wednesday 9 March 2016

ODD OR EVEN


Write a program to find whether a given integer is an odd number or even number.

Input Format: 
Input consists of a single integer.

Output Format: 
Output consists of a single line. Refer sample output for the format.
Sample Input 1: 
3
Sample Output 1: 
3 is an odd number

Sample Input 2: 
44
Sample Output 2: 
44 is an even number

Code:


  #include<stdio.h>
int main(){
  int a;
  scanf("%d",&a);
  if(a%2==0)
    printf("%d is an even number",a);
    else
      printf("%d is an odd number",a);
    
  return 0;
}

1 comment: