please i need help because i am beginner in c progtamming!
i want in selection 1 to intrance grades from keyboard in array[7],from 0 to 10.
in selection 2,that grades are display and the average of them.
in selection 3 i want to sort them with bubblesort function,inside the code.
in selsction 4 ,that i search of one grade from the array and display where it found,or the message "not found",it become with binary search!
thanks a lot
//grades
#include <stdio.h>
#include <stdlib.h>
int grades[7];
int idx;
int temp;
int total=0;
void ingrade(); /*dilosis*/
void display_grade();
int search_grade();
int main(void)
{
int selection;
printf("************************************************************");
printf("\n* Type 1 for inside grade");
printf("\n* Type 2 for display grade and average");
printf("\n* Type 3 for shorting of 7 grades");
printf("\n* Type 4 for searching grade");
printf("\n* Type 5 for exit\n");
printf("\n***********************************************************");
for(idx=0;idx<7;idx++)
do
{
printf("\nPress the number of your selection\n");
scanf("%d", &selection);
if (selection == 1)
{
printf("Enter grade\n");
ingrade(); /*klisi*/
break;
}
if (selection == 2)
{
printf("display grades and average\n");
display_grade();
break;
}
if (selection == 3)
{
printf("Sort list\n");
break;
}
if (selection == 4)
{
printf("Search grade from List\n");
break;
}
if (selection == 5) {
printf("stop");
return 0; // quit the program
}
else
{
printf("\n\n\nselection is not a valid selection");
continue;
}
}
while(1) ; // while goes at the end of a do/while loop
return 0;
}
void ingrade()
{
int idx;
int grades[7];
for(idx=0;idx<7;idx++)
scanf("%d",&grades[idx]);
printf("===========\n");
}
void display_grade()
{
int k;
int grades[7];
int mo;
int temp;
for(k=0;k<7;k++)
temp=temp+grades[k];
mo=temp/7;
printf("\n grade=%d\n",grades[k]);
printf("\n mo=%d\n",mo);
}
/*int search_grade(int grades[7],int target)
{
int l=0,m;
int h,middle;
while(l<=h)
{
m=(1+h)/2;
if(grades[middle]==target)
return middle;
else if(grades[middle]<target)
l=m+1;
else
h=m-1;
}
return -1;
}
*/