Write a program that will read in N integers from keyboard input into an array. The size of the array N will be entered on the keyboard. The program will tabulate the output as shown below: the first column should show the list of distinct array elements sorted in ascending order, while the second column should show the number of occurrences of each element. Sample input: 9, 15, 7, 9, 3, 7, 3, 3,7, 6, 3, 20 Expected output: count 3. 4 6 1 7 3 15 1 20 1

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 11PE
icon
Related questions
Question
100%

This is my C++ Codes for the problem but it has errors when I run it. Can you fix the errors? Please still use header files iostream. This is a topic under Data Structures: Arrays.

//Start of program
#include <iostream>
#define TRUE 0
#define FALSE 1

using namespace std;

int main()
{
//Declaration of array
int A[50];

//Display the first element of the array A
cout << "The value of the first element of the array A is: " << A[0] << endl;

//Store the value 26 in 25th element of array A
A[24] = 26;

//Store the computed value in 10th element of array A
A[9] = (A[39] * 3) + 10;
cout << "The value of the 10th element of the array A is: " << A[9] << endl;

int n = 0; //Subscript of array A

//For loop
for (int i = 0; i < n; i++)
{
if (n / 2 == 0 || n / 3 == 0) //If subscript is a multiple of 2 or 3
{
cout << A[i] << " " << endl; //Display the value of an element of array A
}

if (n / 2 != 0 || n / 3 != 0) //If subscript is not a multiple of 2 or 3
break; //Break out of loop
}

//End of program
return 0;
}

Write a program that will read in N integers from keyboard input into an array. The size of
the array N will be entered on the keyboard. The program will tabulate the output as shown
below: the first column should show the list of distinct array elements sorted in ascending
order, while the second column should show the number of occurrences of each element.
Sample input: 9, 15, 7, 9, 3, 7, 3, 3,7, 6, 3, 20
Expected output:
count
3.
4
6
1
7
3
15
1
20
1
Transcribed Image Text:Write a program that will read in N integers from keyboard input into an array. The size of the array N will be entered on the keyboard. The program will tabulate the output as shown below: the first column should show the list of distinct array elements sorted in ascending order, while the second column should show the number of occurrences of each element. Sample input: 9, 15, 7, 9, 3, 7, 3, 3,7, 6, 3, 20 Expected output: count 3. 4 6 1 7 3 15 1 20 1
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning