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);
//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);
}
{
printf ("%d is an even number.", number);
}
else
{
printf ("%d is an odd number.", number);
}
};
Output
Input number: 19
19 is an odd number.
No comments:
Post a Comment
Please do not post spam links.