Thursday, 28 January 2016

Another example of if condition for odd and even number

  Write a program which can read an integer value from key board and test weather it is odd or even.
      #include<stdio.h>
      #include<conio.h>
      void main(){
       int num,m;
       printf("\nEnter an inter vlaue =");
       scanf("%d",&num);
       m = num%2;
       if(m == 0)
        {
          printf("\n%d is Even");
        }
       else
        {
          printf("\n%d is Odd");
        }
          getch()

       }

No comments:

Post a Comment