Skip to content

Commit df6c1f5

Browse files
committed
a function that checks for a digit (0 through 9).
1 parent 241adf4 commit df6c1f5

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed
16.4 KB
Binary file not shown.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
/*
3+
* File: 1-isdigit.c
4+
* Auth: Brennan D Baraban
5+
*/
6+
7+
#include "main.h"
8+
9+
/**
10+
* _isdigit - Checks for a digit (0-9).
11+
* @c: The number to be checked.
12+
*
13+
* Return: 1 if the number is a digit, 0 otherwise.
14+
*/
15+
int _isdigit(int c)
16+
{
17+
if (c >= '0' && c <= '9')
18+
return (1);
19+
20+
else
21+
return (0);
22+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include "main.h"
2+
#include <stdio.h>
3+
4+
/**
5+
* main - check the code
6+
*
7+
* Return: Always 0.
8+
*/
9+
int main(void)
10+
{
11+
char c;
12+
13+
c = '0';
14+
printf("%c: %d\n", c, _isdigit(c));
15+
c = 'a';
16+
printf("%c: %d\n", c, _isdigit(c));
17+
return (0);
18+
}

0 commit comments

Comments
 (0)