-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray.c
More file actions
52 lines (45 loc) · 646 Bytes
/
array.c
File metadata and controls
52 lines (45 loc) · 646 Bytes
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
#include <stdio.h>
#include <string.h>
void fillList(int arr[], int sz, int high)
{
int k;
for(k = 0; k < sz; ++k)
{
arr[k] = rand() % high + 1;
}
}
void printList(int arr[], int sz)
{
int k;
for(k = 0;k < sz; ++k)
{
printf("%2d ", arr[k]);
}
printf("\n");
}
int countFreq(int ar[], int sz, int target)
{
int many = 0;
int k;
for(k = 0; k < sz; ++k)
{
if(ar[k] == target)
{
many++;
}
}
return many;
}
int main()
{
int A[10];
int N = 10;
int dice[5];
fillList(A, N, 50);
printList(A, N);
fillList(dice, 5, 6);
printList(dice, 5);
res = countFreq(dice, 5, 2);
printf("%d 2s in the list\n");
return 0;
}