Write a program that reads in a list of integers into an arraywith base type int
ID: 3619220 • Letter: W
Question
Write a program that reads in a list of integers into an arraywith base type int. Provide the facility to either read this arrayfrom the keyboard or from a file, at the user's option. If the userchooses file input, the program should request a file name. You mayassume that there are fewer than 50 entries in the array. Yourprogramm determines how many entries there are. The output is to bea two column list. The first column is a list of the distinct arrayelements; the second column is the count of the number ofoccurrences of each element. The list should be sorted on entriesin the first column, largest to smallest. For example, for the input -12 3 -12 4 1 1 -12 1 -1 1 2 3 4 2 3 -12 the output should be N Count 4 2 3 3 2 2 1 4 -1 1 -12 4 Write a program that reads in a list of integers into an arraywith base type int. Provide the facility to either read this arrayfrom the keyboard or from a file, at the user's option. If the userchooses file input, the program should request a file name. You mayassume that there are fewer than 50 entries in the array. Yourprogramm determines how many entries there are. The output is to bea two column list. The first column is a list of the distinct arrayelements; the second column is the count of the number ofoccurrences of each element. The list should be sorted on entriesin the first column, largest to smallest. For example, for the input -12 3 -12 4 1 1 -12 1 -1 1 2 3 4 2 3 -12 the output should be N Count 4 2 3 3 2 2 1 4 -1 1 -12 4Explanation / Answer
please rate - thanks I was lazy, should have used some functions, for swap at least #include #include using namespace std; int main() {ifstream in; int i=0,j,n=50,max=0,number,t,input; char filename[80]; bool found,file=false; int nums[50]={0},count[50]={0}; coutinput; if(input==1) {coutfilename; in.open(filename); if(in.fail()) //is it ok? { coutnumber; if(!in) number=-9999; } else {coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.