-
Notifications
You must be signed in to change notification settings - Fork 0
/
char_pack.c
83 lines (72 loc) · 1.24 KB
/
char_pack.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "main.h"
/**
* _isalpha - a function that checks
* if the given char is alphabet or not
*
* @c: checks input of function
*
* Return: return 1 if 'c' is alphabet
* otherwise return 0
*/
int _isalpha(int c)
{
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
return (1);
return (0);
}
/**
* _islower - a function that checks
* if the given char is lower or not
*
* @c: checks input of function
*
* Return: return 1 if 'c' is lower
* otherwise return 0
*/
int _islower(int c)
{
if (c >= 'a' && c <= 'z')
return (1);
return (0);
}
/**
* _isupper - a function that checks
* if the given char is upper or not
*
* @c: checks input of function
*
* Return: return 1 if 'c' is upper
* otherwise return 0
*/
int _isupper(int c)
{
if (c >= 'A' && c <= 'Z')
return (1);
return (0);
}
/**
* _to_upper - convert letter to upper case
*
* @c: letter to be converted
* Return: char
*/
char _to_upper(char c)
{
if (_islower(c))
return (c - 'a' + 'A');
else
return (c);
}
/**
* _to_lower - convert letter to lower case
*
* @c: letter to be converted
* Return: char
*/
char _to_lower(char c)
{
if (_isupper(c))
return (c - 'A' + 'a');
else
return (c);
}