Hi guys,
Could someone help me on this, the problem is:
Using array, Ask for 10 integer inputs then display the frequency distribution of the inputs. say,
Example Output:
Enter input 1: 2
Enter input 2: 2
Enter input 3: 3
Enter input 4: 4
Enter input 5: 5
Enter input 6: 6
Enter input 7: 5
Enter input 8: 4
Enter input 9: 2
Enter input 10: 1
2s - 3
3s - 1
4s - 2
5s - 2
6s - 1
1s - 1
Here's my own code:
#include<iostream.h>
#include<conio.h>
void print_array(int a[], int length)
{
cout << "Enter the number of elements of the array:" << endl;
for(i=0;i<length;i++)
{
cin >> a[i];
}
for(i=0;i<length;i++)
{
cout << "There are ____ " << a[i] << "s Integers" << endl;
}
}
void main()
{
clrscr();
int input_num[]={0,0,0,0,0,0,0,0,0,0};
print_array(input_num,10);
getch();
}
Thanks in advanced.