int list[LIMIT], i, j, val, count, flag, test[LIMIT], c = 0;
//enter the values
for (i = 0; i < LIMIT; i++)
{
cout << "Enter The Elements : ";
cin >> list[i];
if (list[i] == 0)
break;
}
//count the occurence of each value
for (j = 0; j < LIMIT; j++)
{
count = 0;
flag = 1;
val = list[j];
//counts each value's occurence and if the value is 0 break
for (i = 0; i < LIMIT; i++)
{
if (val == list[i])
count++;
else if (list[i] == 0)
break;
}
//checks whether the value has been already counted (flag = 0) or not (flag stays 1)
for (i = 0; i < c; i++)
{
if (test[i] == val)
flag = 0;
}
//if the value has not been counted print
if (flag == 1)
{
cout << "The Occurence Of The Number " << val << " is " << count << endl;
test[c] = val;
c++;
}
}