#include <stdio.h>
int frequency (int theArray[], int n, int x);
int main(void) {
int theArray[5] = {5, 12, 23, 23, 28};
int xcount;
int x = 23;
int n = 5;
xcount = frequency(theArray, n, x);
printf("%d", xcount
); // print output return 0;
}
// ******************************************
// Function : frequency
//
// Description : shows frequency of variables occuring
//
// Parameters : count - Keep a running count
// frequency - how often variables occur
// TheArray - Holds the numbers to run through program
//
// Returns : Frequency - Frequency of how many times 23 appears
// **************************************************************************
int frequency (int theArray[], int n, int x)
{
int frequency; /* how many times n is found */
int count = 0; /* initialize count */
/* loop through every element in theArray */
for (int i = 0; i < n; ++i)
{
if(theArray[i] == x)
{
++count;
}
}
return count;
}// return count
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgZnJlcXVlbmN5IChpbnQgdGhlQXJyYXlbXSwgaW50IG4sIGludCB4KTsKCmludCBtYWluKHZvaWQpIHsKCWludCB0aGVBcnJheVs1XSA9IHs1LCAxMiwgMjMsIDIzLCAyOH07CglpbnQgeGNvdW50OwoJaW50IHggPSAyMzsKCWludCBuID0gNTsKCXhjb3VudCA9IGZyZXF1ZW5jeSh0aGVBcnJheSwgbiwgeCk7CglwcmludGYoIiVkIiwgeGNvdW50KTsgLy8gcHJpbnQgb3V0cHV0CglyZXR1cm4gMDsKfQovLyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKLy8gRnVuY3Rpb24gOiBmcmVxdWVuY3kKLy8KLy8gRGVzY3JpcHRpb24gOiBzaG93cyBmcmVxdWVuY3kgb2YgdmFyaWFibGVzIG9jY3VyaW5nCi8vCi8vIFBhcmFtZXRlcnMgOiBjb3VudCAtIEtlZXAgYSBydW5uaW5nIGNvdW50Ci8vCQkJCWZyZXF1ZW5jeSAtIGhvdyBvZnRlbiB2YXJpYWJsZXMgb2NjdXIKLy8JCQkJVGhlQXJyYXkgLSBIb2xkcyB0aGUgbnVtYmVycyB0byBydW4gdGhyb3VnaCBwcm9ncmFtCi8vCi8vCQkJCVJldHVybnMgOiBGcmVxdWVuY3kgLSBGcmVxdWVuY3kgb2YgaG93IG1hbnkgdGltZXMgMjMgYXBwZWFycwovLyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgppbnQgZnJlcXVlbmN5IChpbnQgdGhlQXJyYXlbXSwgaW50IG4sIGludCB4KQp7CiAgICBpbnQgZnJlcXVlbmN5OyAvKiBob3cgbWFueSB0aW1lcyBuIGlzIGZvdW5kICovCgkKICAgIGludCBjb3VudCA9IDA7IC8qIGluaXRpYWxpemUgY291bnQgKi8KICAgIAoKICAgIC8qIGxvb3AgdGhyb3VnaCBldmVyeSBlbGVtZW50IGluIHRoZUFycmF5ICovCiAgICBmb3IgKGludCBpID0gMDsgaSA8IG47ICsraSkKICAgIHsKICAgICAgIGlmKHRoZUFycmF5W2ldID09IHgpCiAgICAgICB7CiAgICAJKytjb3VudDsKICAgICAgIH0KICAgIH0KCiAgICByZXR1cm4gY291bnQ7Cn0vLyByZXR1cm4gY291bnQKCg==