-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdigitChecker2.c
44 lines (36 loc) · 976 Bytes
/
digitChecker2.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
/*
* File: digitChecker2.c
* Author: Mudathir Lawal
* Email: [email protected]
* GitHub: github.com/mudathirlawal
* Last Edit: 9th September, 2018.
* Version: 1.1.0 EN
*
* Purpose: To check if character input by
* user is a digit between 0 - 9.
*/
#include <stdio.h>
#include <ctype.h>
void checkChar( int );
void checkChar( int characterInput )
{
const char EC = ' ';
int digitCondition = isdigit( characterInput );
if ( !digitCondition )
{
printf( "\n\tThe character you entered, %c, is NOT a digit; kindly", characterInput );
printf ( "\n\t%c%c%c%c%c%center a digit between 0 - 9, and try again.\n\n", EC, EC, EC, EC, EC, EC );
return;
}
else
{
printf ( "\n\tThe character you entered, %c, is indeed a digit.\n\n", characterInput );
}
}
int main ( void )
{
int charInput;
printf ( "\n\tEnter any character between 0 - 9: " );
charInput = getchar();
checkChar ( charInput );
}