Answer to Question #167896 in Programming & Computer Science for norelyn

Question #167896

1.Write a program using one-dimensional array that accept 5 input values from the keyboard. Then it 

should also accept a number to search. This number is to be searched if it is among the five inputs. If 

it is found, display the message “Searched number is found!”, otherwise display “Search number is not 

included in the list”.


Sample Output:

Enter five values:

5 10 15 20 25

Enter a number to search: 15

Search number is found!


1
Expert's answer
2021-03-02T00:52:33-0500
#include <iostream>  
  
using namespace std; 
  
//The start point of the program
int main() 
{   
	//one-dimensional array that accept 5 input values from the keyboard. 
	float values[5];
	float searchNumber;
	bool isFound=false;
	cout<<"Enter five values\n"; 
	for(int i=0;i<5;i++){
		cin>>values[i];
	}
    //accept a number to search.
	cout<<"Enter a number to search: ";
	cin>>searchNumber;
	//This number is to be searched if it is among the five inputs
	for(int i=0;i<5;i++){
		if(values[i]==searchNumber){
			isFound=true;
		}
	}
	//If it is found, display the message "Searched number is found!"
	if(isFound){
		cout<<"Searched number is found!\n\n";
	}else{
		//otherwise display "Search number is not  included in the list".
		cout<<"Search number is not  included in the list\n\n";
	}
    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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS