67 095
Assignments Done
99,3%
Successfully Done
In November 2018

Answer to Question #18469 in C++ for Amr

Question #18469
7- Write a function that displays the frequency of occurrence of an element entered by the user in a stored array. The array always has the following elements: 4, 2, 7, 10, 9, 7, 6, 10, -8, 7, 9.
Sample Executions:
Enter a number: 7
The number 7 occurred 3 times in your array.
Press any key to continue

Enter a number:17
The number 17 occurred 0 times in your array.
Press any key to continue
Expert's answer

#include <iostream>

using namespace std;


int arrayofnumbers[]={4, 2, 7, 10, 9, 7, 6, 10, -8, 7, 9};
int main()
{
int number=0;
int times=0;
cout<<"Enter a number: ";
cin>>number;
for(int i=0;i<11;i++){
if(number==arrayofnumbers[i]){
times++;
}
}
cout<<"The number "<<number<<" occurred
"<<times<<" times in your array.";
cout<<"
Press any key to continue";
cin>>number;
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions