Hi everyone, just self studying C Programming for the summer. I was wondering if you could give me some advice on what to do here. In the book, one of the challenges ask me to as the user to input 10 numbers, and then sort and print the 10 numbers in ascending or descending order.
I am not sure how to sort the arrays in order.
My Check() function was just to experiment with how arrays work.
I plan to put the code for sorting the stored numbers in function store()
Sincerely,
Jomoka
Code:
#include <stdio.h>
//function
void check();
int sort(int, int);
//Global Variables
int x;
int number[10];
main() {
int iStore = 0;
int iResponse = 0;
printf("\nWelcome to the number storage thing!\n");
printf("\n You are allowed to store 10 numbers\n");
//For loop that goes through each array and ask the user to input a number to
//store in each 10 arrays from address 0 to 9
for (x = 0; x < 10; x++) {
printf("Enter number to store in storage %d: \t", x);
scanf("%d", &iStore);
number[x] = iStore;
}//End For loop
check();
}
//Function Definition
check() {
//The variables below is to understand arrays, checking to see
//if the numbers stored will actually show the element it's stored in
int iValue;
int iFound = -1;
//The code to check what element this value is located in
printf("Find value to search for: ");
scanf("%d", &iValue);
for (x = 0; x < 10; x++) {
if (number[x] == iValue) {
iFound = x;
break;
}
}
if (iFound > -1)
printf("\nI found your search value in element %d\n", iFound);
else
printf("\nSorry, your search value was not found\n");
}
//Function Definition
sort() {
}