66 976
Assignments Done
99,2%
Successfully Done
In November 2018

Answer to Question #31325 in C++ for Ithamar

Question #31325
write a function that takes 3 parameters: an array,its size and an integer.This function should return true if that integer was found in that array,false otherwise.Write a program that asks the user to enter 5 numbers and save then in an array ARR.Ask the user to enter an integer,use the function above to check if that integer was found in the array ARR.
Expert's answer
#include <iostream>
#include <conio.h>

using namespace std;

//function check if integer is in array
bool findInteger(int ARR[],int size,int integernumber){
bool find =false;
for(int i=0;i<size;i++){
if(integernumber==ARR[i]){
find =true;
break;
}
}
return find;
}
//mai function
int main()
{
int ARR[100];//array
int integer;//integr number
for(int i=0;i<5;i++){
cout<<"Enter number "<<(i+1)<<":
";//input number
cin>>ARR[i];//read number
}
//
cout<<"Enter intger: ";
cin>>integer;
//show result
if(findInteger(ARR,5,integer)==true){//r,use the function above to check if
that integer was found in the array ARR.
cout<<"This integer was found in the array ARR.";
}else{
cout<<"This integer was not found in the array ARR";
}

getch();//delay
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