I can't run the programme, please assist to check the error.
Thank you in advance for your assistance.

Question:
1. Develop an application program that creates a list of integer test score value in an array, sorts the array in increasing order and searches it for a test score value. The size of the list is a variable, which the user inputs the value.

The application program consists of THREE(3) user-defined function:
a) input_array ia used to creates the list an array
b) sort_array is for sorting
c) search_ordered array is for searching data

Example of output:

How many test scores? Enter an interger : 5
Enter a test score : 89
Enter a test score : 77
Enter a test score : 100
Enter a test score : 67
Enter a test score : 85

Unsorted array:
0 89
1 77
2 100
3 67
4 85

Sorted array:

0 67
1 77
2 85
3 89
4 100

Enter search key, an integer : 89
Search is successful. 89 is the 4th list element.


My coding:

#include <stdio.h>
int linearsearch (int [], int,int);
{
int main()
int testscore, element, searchkey;
printf ("How many test scores? Enter an integer : ");
scanf ("%d", &testscore );

void main (void);
{
int x[5], pass, temp, i;
for (i = 0; i<= 4; i++)

{
/* to enter the test score*/
printf ("Enter the test score : " , i);
scanf ("%d", &(x));
}

/* to unsorted array*/
printf ("\nUnsorted array: \n");
for (i = 0; i<= 4; i++)
printf ("%7d%13d\n", i, x [ i ]);
for (pass = 1; pass <= 5-1; pass++ )
for ( i =0; i<= 5-2; i++ )
if ( x > x )
{
temp = x ;
x = x ;
x = temp;
}

/* to sorted array */
printf ("\nSorted array: \n" );
for (i = 0; i <= 5-1; i++)
printf ("%7d%13d\n", i, x [ i]);
}
/* Search key */
for (i = 0; x <= 4-1; i++)
x = 2*x;
printf (" Enter search key, an integer : ");
scanf ("%d", &searchkey);
element = linearsearch (i, searchkey, i);
{
if ( element != -1)
printf ("Search is successful: %d\n", element );
}else
printf ("Search is failed\n");

return 0;
}
int linearsearch ( int array [1], int key ,int n);
{
int n;
for (n = 0; n <= 5-1; ++n)
if array [n] == key)
return n;
}
return-1;

This article has been dead for over six months. Start a new discussion instead.