Answer to Question #311912 in C++ for Helpmeplss

Question #311912

Using an array , write a C++ program that can hold ten integer input from user. Display those values on the screen , and their prompt the user an integer to search within the array , and count the number of times the item is found.



Enter 10 values in array :


1


2


3


4


5


6


7


8


8


Values in array now : 1 2 3 4 5 6 7 8 8


Enter the value to find : 8


8 was found in 2 times.


____________________________


Process excited with return value 0


Press any key continue . . .

1
Expert's answer
2022-03-15T05:54:18-0400
#include <iostream>

using namespace std;

int main()
{
	int arr[10];
	cout << "Enter 10 values in array :";
	for (int i = 0; i < 10; i++)
	{
		cin >> arr[i];
	}
	cout << "Values in array now: ";
	for (int i = 0; i < 10; i++)
	{
		cout<< arr[i]<<" ";
	}
	int fnd;
	int count = 0;
	cout << "\nEnter the value to find :";
	cin >> fnd;
	for (int i = 0; i < 10; i++)
	{
		if (arr[i] == fnd)count++;
	}
	cout << endl;
	cout <<fnd<<" was found in "<< count<<" times";
}

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 the first!

Leave a comment