# 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.

Expert's answer

#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;

}

#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;

}

## Comments

## Leave a comment