Write A Program In C To Check Whether The No Is Even Or Odd

Write A Program In C To Check Whether The No Is Even Or Odd


#include<stdio.h> /* Header file for input/ output functions like                                             scanf(), printf() functions */
#include<conio.h> /* Header file for console functions like clrscr(),                                      getch() functions */

void main()  /* Execution of any program starts at main() function */
 {                  /*  main body block begins */ 
   int num;   /* Declare a variable num of integer type */
   clrscr();    /* This function is used to clear the console screen */
   printf("Enter a number\n"); /* Just a message for a user what to do
                                                */
   scanf("%d",&num); /*  It takes an input as integer and store it at                                                the address of  variable num */
   if(num%2==0)     /* It checks the divisibility of input number by 2                                     and gives the remainder as a result. If the input                                     number is divisible by 2, then if statement will
                                   be executed otherwise else statement */
     printf("%d is even",num);
   else
     printf("%d is odd",num);
   getch();       /* This function is used to hold the console screen until
                            the user hit any key */
  } /*  main body block ends */

Popular posts from this blog

IGNOU Solved Assignment 2023-24 | BCS-012 Basic Mathematics BCA(I)012/Assignment/2023-24

Generation Of Computer | Computer Generation | कंप्यूटर की पीढ़िया

Fibonacci Series In C-Gaurav Pali