-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path2_CP2_oefening3.c
66 lines (60 loc) · 1.71 KB
/
2_CP2_oefening3.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
#include <stdio.h>
#include <string.h>
int telAantalKlinkers(char *data);
int telAantalLetters(char *data);
int telAantalCijfers(char *data);
int main()
{
char testData[] = "$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47";
int aantalKlinkers = telAantalKlinkers(testData);
int aantalCijfers = telAantalCijfers(testData);
int aantalMedeklinkers = telAantalLetters(testData) - aantalKlinkers;
printf("Aantal Klinkers: %d\n", aantalKlinkers);
printf("Aantal Medeklinkers: %d\n", aantalMedeklinkers);
printf("Aantal Cijfers: %d\n", aantalCijfers);
printf("Aantal Interpuncties: %d\n", strlen(testData)-aantalCijfers-aantalKlinkers-aantalMedeklinkers);
return 0;
}
//CAPS only
int telAantalLetters(char *data)
{
unsigned int i = 0;
unsigned int aantalLetters = 0;
for(i = 0; i < strlen(data); i++)
{ //CAPS ONLY
if(*(data+i) >= 65 && *(data+i) <= 90)
{
aantalLetters += 1;
}
}
return aantalLetters;
}
int telAantalCijfers(char *data)
{
unsigned int i = 0;
unsigned int aantalLetters = 0;
for(i = 0; i < strlen(data); i++)
{
if(*(data+i) >= 48 && *(data+i) <= 57)
{
aantalLetters += 1;
}
}
return aantalLetters;
}
//CAPS only
int telAantalKlinkers(char *data)
{
unsigned int i = 0;
unsigned int aantalKlinkers = 0;
for(i = 0; i < strlen(data); i++)
{ //CAPS ONLY
if(*(data+i) == 65 || *(data+i) == 69 \
|| *(data+i) == 73 || *(data+i) == 79\
|| *(data+i) == 85 )
{
aantalKlinkers += 1;
}
}
return aantalKlinkers;
}