Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using for loop. And please do explain. Many thanks! 7.[15] Consider the followin

ID: 3674548 • Letter: U

Question

 Using for loop. And please do explain. Many thanks! 7.[15] Consider the following code fragment:              const int SIZE=10;             int myarray[SIZE];              // here goes the code that assigns the array             // values to each element of the array             // assume it already exists do not write it              int number;                  cout << "Input the number to search for: ";             cin >> number;              //             // here goes the code you need to write             //          Complete this fragment such that the resultant code checks         whether the input number is in the array "myarray" and outputs         the result. Specifically, your code needs to produce one of         the two outputs          example one:               Input the number to search for:  60              FOUND          example two               Input the number to search for: 33              NOT FOUND           That is, depending on the input your code needs to output          either "FOUND" or "NOT FOUND". Write out the code. Explain          how it works. 

Explanation / Answer

Please find the required code segment below :

string result = "NOT FOUND";
for(int i=0; i<SIZE; i++){

if( myarray[i]==number){
result = "FOUND";
break;
}
}
cout << result << endl;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote