use repil.it edit my code please i already did all partbut need to edit more its run for some not shwing all
intro to C-programin be sure toedit on my code very basic and add good comments thankyou
1-Write a program that requests 5 integers from the user andstores them in an array. You
may do this with either a for loop OR by getting a string fromstdin and using sscanf to store formatted input in each spot in thearray.
2-Add a function to the program, called get_mean that determinesthe mean, which is the average of the values. Thefunction should be passed the array and the size of thearray, but use const so that it cannot be changed, onlyaccessed. It should return a double, which is the calculatedmean. The main function will print the value.
//Function prototype:double get_mean(const int [], int);
3-Create a function called search_array that searches the arrayfor the answer to life, the universe, and everything - the integer42. If 42 is found, print You wrote The Answer to the GreatQuestion!. If it is not found, print You might not know the answerto Life, the Universe, and Everything. Set a global variable calledsearch_for to store the number to search for (42)
//Function prototype:void search_array(const int [], int);
4-Create a function called sort_array. The array should besorted in descending order. The function should bepassed the array and the size of the array. The function does notreturn a value; the array is changed by the function. Themain function will print the sorted array (you may create a printarray function if desired).
//Function prototype:void sort_array(int [], int);
**{note} from teacher need to edit
Why are you creating the const array
If you make it const you can't change theelaments.
For size calc use the function sizeof()
you have declare search_for as globalvariable
in the below statement \"void search_array(constmy_array[],int size){\" you have to give datatype ofarray.
variable temp scope is main function, you need todeclare the temp variable in sort_array()
_____________________________________________\
/
//libraries
//files that we need to include
#include
#include
#include
//Function prototype:
double get_mean(const int [], int);
void search_array(const int [], int);
void sort_array(int [], int);
int main(void){
int my_array[5];
//input requesting from user
printf(\"Please Enter 5 integers, hit enter after eachinput:\n\");
//for loop to get input
for(int i=0; i<5; i++){
scanf(\"%d\",&my_array[i]);
}
//function call for mean of the integer
double m=get_mean(my_array,5);
//print mean
printf(\"The mean of array is:%.2f\n\",m);
search_array(my_array,5);
sort_array(my_array,5);
printf(\"Array sorted in order: \");
return 0;
}
//function definition to get_mean
double get_mean(const int my_array[],int size){
double sum=0.0;
for(int i=0; i
//calculate to get mean
sum+=my_array[i];
}
double get_mean = sum/size;
return get_mean;
}
//function definition to search_array
void search_array(const int my_array[], int size){
int search_for = 42;
for(int i=0;i
if(my_array[i]==search_for){
//found
printf(\"You wrote The Answer to the Great Question!\n\");
return;
}
}
//not found
printf(\"You might not know the answer to Life, the Universe, andEverything\n\");
}
// Function to print an array
void printArray(int my_array[], int size)
{
int i;
for (i = 0; i < size; i++)
printf(\"%d \", my_array[i]);
printf(\"\n\");
}
// Function to Sort array
void sort_array(int my_array[], int size){
int temp;
for(int i=0;i
for (int j=i+1;j
if (my_array[i] > my_array[j]){
temp=my_array[i];
my_array[i]=my_array[j];
my_array[j]=temp;
}
}
}
}