-
Notifications
You must be signed in to change notification settings - Fork 1
/
10.c
34 lines (32 loc) · 922 Bytes
/
10.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
#include <stdio.h>
/**
* A function that converts an ASCII character to lower case.
*
* @param int c The character to be converted
*
* @return int Resultant character
*/
int lower(int c)
{
return (c >= 'A' && c <= 'Z') ? c + 'a' - 'A' : c;
}
/**
* A program to test bitcount.
*/
main()
{
printf("lower('a')\t=>\t%c\n", lower('a'));
printf("lower('b')\t=>\t%c\n", lower('b'));
printf("lower('c')\t=>\t%c\n", lower('c'));
printf("lower('d')\t=>\t%c\n", lower('d'));
printf("lower('e')\t=>\t%c\n", lower('e'));
printf("lower('A')\t=>\t%c\n", lower('A'));
printf("lower('B')\t=>\t%c\n", lower('B'));
printf("lower('C')\t=>\t%c\n", lower('C'));
printf("lower('D')\t=>\t%c\n", lower('D'));
printf("lower('E')\t=>\t%c\n", lower('E'));
/**
* Following example only throws compiler warnings.
* 'printf("lower(❤️)\t=>\t%c\n", lower("❤️"));'
*/
}