Tuesday, 16 September 2014

Write a C program "if...else" statement

 Write a C program to check whether a number entered by user is even or odd

#include <stdio.h>
int main(){
      int num;
      printf("Enter a number you want to check.\n");
      scanf("%d",&num);
      if((num%2)==0)          //checking whether remainder is 0 or not.
           printf("%d is even.",num);
      else
           printf("%d is odd.",num);
      return 0;
}




No comments:

Post a Comment