Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Here is the problem I am stuck on: Write a C++ program that reads integer values

ID: 3619911 • Letter: H

Question

Here is the problem I am stuck on:

Write a C++ program that reads integer values from a user. Your program should display the biggest number (= largest one) among the input values. Your program should also display a list of the distinct elements in the input and the number of occurrences of each distinct value. The following presents a sample run of your program. In this
program, you can assume that the number of input values from a user is less than 30.

So it should output:

How many input values [max: 30]?
5
Enter 5 numbers.
2
1
2
-3
2
Biggest Number: 2
Number Count
-3 1
1 1
2 3

Finding the biggest number is easy, but its the counting the numbers that I am unsure on. Any help would be very much appreciated.

Explanation / Answer

please rate - thanks your output is sorted, but you didn't say it had to be message me if you need that change. otherwise hope this helps
#include <iostream>
using namespace std;
int main()
{
int i,j,n,max=0,found,number,biggest;
int nums[30],counts[30];
cout<<"How many input values [max: 30]? ";
cin>>n;
while(n<1||n>30)
    {cout<<"Invalid entry ";
      cout<<"How many input values [max: 30]? ";
      cin>>n;
      }
for(i=0;i<n;i++)
nums[i]=0; //initialize array with 0s
for(i=0;i<n;i++)
{cout<<"Enter number "<<i+1<<": ";
cin>>number;
if(i==0)
    biggest=number;
else
    if(number>biggest)
        biggest=number;
found=0;
for(j=0;j<max;j++)
if(nums[j]==number) //is it a new number?
   {found=1; //found-not new
    counts[j]++;
   }
if(found==0)
{nums[max]=number; //enter only new numbers
counts[max]=1;
max++;
}
}
cout<<"Biggest number: "<<biggest<<endl;
cout<<"Number count ";
for(i=0;i<max;i++)
    cout<<nums[i]<<" "<<counts[i]<<endl;
system("pause");
return 0;
}