Digital जीवन

Free Online Education for India...

Full width home advertisement

Computer Basic

C Programming

Engineering Graphics

Post Page Advertisement [Top]

Dr. A.P.J. Abdul Kalam Technical University, Lucknow

KCS101 / KCS201 Programming for Problem Solving - Using C Language


Lab Exercises


8. Write a program that finds whether a given number is even or odd.


/*
 File: Prgrm08.c
 Author: Aditya Saini
 Date: Sept 24, 2019
 Description: Program to find whether a given number is even or odd.
*/

#include <stdio.h>

int main (void)
{
               int number;

               //Input number.
               printf ("Input number: ");
               scanf ("%d", &number);

               //Finding whether the number is even or odd and output the result.
               if (number % 2 == 0)
               {
                              printf ("%d is an even number.", number); 
               }
               else
               {
                              printf ("%d is an odd number.", number);
               }

               return 0;
};

Output

Input number: 19
19 is an odd number.



No comments:

Post a Comment

Please do not post spam links.

Bottom Ad [Post Page]

| Designed by Colorlib