/*count the occurrences of a value in an array */
#include <stdio.h>
int main(void)
{
int myarray[] = {4,9,7,6,5,8,3,2,1,5};
int count = 0;
int to_find = 5;
for (int i = 0; i < 10; i++){
if (myarray[i] == to_find) count++;
}
printf("# of 5s found: %d\n", count);
return 0;
}
Lypjb3VudCB0aGUgb2NjdXJyZW5jZXMgb2YgYSB2YWx1ZSBpbiBhbiBhcnJheSAqLwoKI2luY2x1ZGUgPHN0ZGlvLmg+CgoKaW50IG1haW4odm9pZCkgCnsKCWludCBteWFycmF5W10gPSB7NCw5LDcsNiw1LDgsMywyLDEsNX07CglpbnQgY291bnQgPSAwOwoJaW50IHRvX2ZpbmQgPSA1OwoJCglmb3IgKGludCBpID0gMDsgaSA8IDEwOyBpKyspewoJCWlmIChteWFycmF5W2ldID09IHRvX2ZpbmQpIGNvdW50Kys7Cgl9CgkKCXByaW50ZigiIyBvZiA1cyBmb3VuZDogJWRcbiIsIGNvdW50KTsKCQoJcmV0dXJuIDA7Cn0=