Hello, I've very recently started to learn to program (in general) with my first language being the ANSI C. I've found an assignment which I'm trying to work on, but without any luck so far.
I encountered two problems, 1st being the fact that bubble sort procedure doesn't work at all, 2nd - the program doesn't want to calculate more than 15 random integers. Here's the code:
Write a short program that will calculate 10 random integers and store them in one-dimensional array, then present stored integers as they are and sorted in decreasing order. Use bubble sort algorithm and rand() function. Use array indexes only!
The range of integers should be passed to your program as execution parameters.
I it may look terryfing to some, but like I've said, I'm very new to programming. I worked to fix this program for almost a day, but without any results. I'd be happy for any help/comments/remarks etc. regarding any part of the program that can be made better/simpler.
int sort (int numbers, int array_size)
for(j=1; j<=b; j++)
temp = numbers[j-1];
numbers[j-1] = numbers[j];
numbers[j] = temp;
int main (int argc, char* argv)
lowerlim = atoi(argv);
upperlim = atoi(argv);
rgn = atoi(argv);
i = 0;
printf("Unsorted elements: ");
for (a = 0;a<(rgn);a++)
store[i] = (rand() % upperlim + lowerlim);
printf("\nSorted elements: ");