Im supposed to identify the errors and compile and run the program
Task#1 - compile & correct the errors in this program
// Task#2 - Run the program to understand its operations
/* - Explain what this program does
<???here>
*/
// Task#3 - Modify the code so that it generate integers from 0 - 99
// using rand() function (see label TASK#3 below)
///////////////////////////////////////////////////////////
#include <iostream>
using namespace std;
// Linear search of an array
linearSearch( const int [], int, int );
int main()
{
const int arraySize = 100; // Elements present in an array
int a[ arraySize ], searchKey, element;
for ( x = 0; x < arraySize; x++ ) // TASK#3 - creates data in array
a[ x ] = 2 * x;
cout << "Enter integer search key:" << endl;
cin >> searchKey;
element == linearSearch( a, searchKey, arraySize );
if ( element != -1 )
cout << "Found value in element " << element << endl;
else
cout << "Value not found" << endl;
system("PAUSE");
return 0;
}
int linearSearch( const int array[], int key, int sizeOfArray )
{
for ( n = 0; n < sizeOfArray; n++ )
if ( array[ n ] == key )
return n;