-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathprogram6.c
47 lines (38 loc) · 1.22 KB
/
program6.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//Write a program which checks whether number is even or odd.
#include <stdio.h> //for printff and scanf
#include <stdbool.h> // for bool data type
////////////////////////////////////////////////////////////////////////////
//
// Function Name: CheckEvenOdd
// Input: Integer
// Output: Boolean
// Description: Checks if input is even or odd
// Author: Swaraj Nitin Mhatre
// Date: 25/04/2023
//
///////////////////////////////////////////////////////////////////////////////
bool CheckEvenOdd(int iNo){
if((iNo % 2) == 0){
return true;
}
else{
return false;
}
}
////////////////////////////////////////////////////////////////////////////////////
// Entry Point Function
////////////////////////////////////////////////////////////////////////////////////
int main(){
int iValue =0; //variable to accept input
bool bRet = false; //variable to accept return value
printf("Please enter number to check whether it is even or odd:\n");
scanf("%d", &iValue);
bRet = CheckEvenOdd(iValue); //function call
if(bRet == true){
printf("%d is even number: ", iValue);
}
else{
printf("%d is Odd number: ", iValue);
}
return 0;
}