# Answer to Question #859 in C++ for alemseged

Question #859
Write an algorithm that counts the number of occurrances of a particular number from a given list of numbers.
1
Expert's answer
2010-10-28T12:38:08-0400
#include <iostream.h>
#define N=5 //counts of list of occuarences numbers
#define K=5 //counts of list numbers
main(){
int i, n, s;// s - counts the number of occurrances
int q;// simple variable
int a[N];// list of occuarences numbers
int b[K];// list of numbers
s=0;
cout<<"Write a list of numbers";
for(i=1; i<=K; i++)
{cin>>q;
b[i]=q;}

cout<<"Write a list of occuarences numbers";
for(i=1; i<=N; i++)
{cin>>q;
a[i]=q;}

for(i=1; i<=K; i++)
{
for(n=1; n<=N; n++)
{
if (b[i]==a[n]) s=s+1;
}
}

cout<<"The rezultat is";
cin>>s;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

#### Comments

No comments. Be the first!

### Ask Your question

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS