In: Computer Science
ASM Programming instructions: For this week the student’s goal is to write an occurrence finding function that builds off of the past two weeks of assembly programming. The requirements for this function are as follows.
The C++ code for this program is as such:
int main()
{
int x[10], occur, count = 0;
cout << "Type in array numbers:" << endl;
for (int i=0; i<10; i++) // reading in integers
{
cin >> x[i];
}
cout << "Type in occurrence value:" << endl;
cin >> occur;
// Finding and printing out occurrence indexes in the array
cout << "Occurrences indices are:" << endl;
for (int i=0; i<10; i++)
{
If (x[i] == occur)
{
cout << i << endl;
count ++;
}
}
cout << "Number of occurrences found:" << endl;
cout << count;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int x[10], occur, count = 0;
cout << "Type in array numbers:" << endl;
for (int i=0; i<10; i++) // reading in integers
{
cin >> x[i];
}
cout << "Type in occurrence value:" << endl;
cin >> occur;
// Finding and printing out occurrence indexes in the array
cout << "Occurrences indices are:" << endl;
for (int i=0; i<10; i++)
{
if(x[i] == occur)
{
cout << i << endl;
count ++;
}
}
cout << "Number of occurrences found:" << endl;
cout << count;
return 0;
}
//Code
//output