You are required to write a code that takes an array of 10 integer values, finds and prints the following: • Each value that appear in the array and its frequency (how many times the value appears in the array). • The value with the maximum frequency. If two or more values have frequencies equal to the maximum frequency, the

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Please help with the min code
JO 100 ll
N 55% D 12:50
INGINIOUS
Assignment 3-B: Values
frequency in an array
Collapse context
You are required to write a code that takes an
array of 10 integer values, finds and prints the
following:
• Each value that appear in the array and
its frequency (how many times the value
appears in the array).
• The value with the maximum frequency.
If two or more values have frequencies
equal to the maximum frequency, the
program prints the minimum value
among these values.
The output should be formated as given by the
following example. If the entered
are: {19, 5, 6, 6, 7, 5, 0, 4, 6, 0} such that
array[0] = 19 and so on, then the program
should output each value and its frequency
array
values
separated by ":" starting from the value of
array [0]. The last line in the output displays
the value with the highest frequency. So, the
output in this example would be like this:
19:1
5:2
Transcribed Image Text:JO 100 ll N 55% D 12:50 INGINIOUS Assignment 3-B: Values frequency in an array Collapse context You are required to write a code that takes an array of 10 integer values, finds and prints the following: • Each value that appear in the array and its frequency (how many times the value appears in the array). • The value with the maximum frequency. If two or more values have frequencies equal to the maximum frequency, the program prints the minimum value among these values. The output should be formated as given by the following example. If the entered are: {19, 5, 6, 6, 7, 5, 0, 4, 6, 0} such that array[0] = 19 and so on, then the program should output each value and its frequency array values separated by ":" starting from the value of array [0]. The last line in the output displays the value with the highest frequency. So, the output in this example would be like this: 19:1 5:2
#include<iostream>
using namespace std;
int main()
int numbers[10];
int i;
for (i=0;i<10;i++)
cin>>numbers[i);
int numbers2[10],j,k;
for (i=0;i<10;i++)
numbers2[i]=-1;
for (i=0;i<10;i++)
{
k=1;
for (j=i+1;j<10;j++)
(numbers[i]==numbers
{
k++;
numbers2[j]=0;
if (numbers2[i]!=0)
{
numbers2[i]=k;
for (i=0;i<10;i++)
{
if(numbers2[i]!=0)
{
cout<<numbers[i<<":"
<<numbers2[i]<<endl;
}
int c=0,max1=0;
for (int b=0;b<10;b++)
{
int rep=numbers[b];
int top=0;
for(int y=0;y<10;y+
{
(numbers[y]==rep)
top++;
if(top>c)
{
max1=rep;
c=top;
cout<<max1<<endl;
return 0;
}
Transcribed Image Text:#include<iostream> using namespace std; int main() int numbers[10]; int i; for (i=0;i<10;i++) cin>>numbers[i); int numbers2[10],j,k; for (i=0;i<10;i++) numbers2[i]=-1; for (i=0;i<10;i++) { k=1; for (j=i+1;j<10;j++) (numbers[i]==numbers { k++; numbers2[j]=0; if (numbers2[i]!=0) { numbers2[i]=k; for (i=0;i<10;i++) { if(numbers2[i]!=0) { cout<<numbers[i<<":" <<numbers2[i]<<endl; } int c=0,max1=0; for (int b=0;b<10;b++) { int rep=numbers[b]; int top=0; for(int y=0;y<10;y+ { (numbers[y]==rep) top++; if(top>c) { max1=rep; c=top; cout<<max1<<endl; return 0; }
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY