You are on page 1of 1

Answer:

#include <iostream>

using namespace std;

int main()
{
int arr[1000],j;
int k=0;

cout << "Program that reads a set of positive integers and outputs how many times a
particular number appears";

cout << " Enter a set of integers (-999 to stop)" << endl;

for(int i=0; i< 1000; i++) // to initialize each element with 0.


arr[i]=0;

// to input the integer until we get -999 to stop reading the int value.
do
{

cin>>j;

if(j== -999)
break;

arr[j]++;

k++;
}
while(k<100);

// for printing the value.


for(int i=0;i<1000;i++)
{
if(arr[i]!= 0)
{
cout<< i<<" "<<arr[i]<<"\n";
}
}

return 0;
}

You might also like