This question was created from Graded Discussion – Buggy Array – CMIS 102 7382
This question was created from Graded Discussion – Buggy Array – CMIS 102 7382 Introduction to Problem Solving and Algorithm Design https://www.coursehero.com/file/35743498/Graded-Discussion-Buggy-Array-CMIS-102-7382-Introduction-to-Problem-Solving-and-Algorithm-Design/
This project is intended to prompt the user to input 10 integer numbers, store those numbers in an array, and then sort the array in ascending order. But I can’t get the bug out my code so it can work properly. I tried different things like adding “#include <math.h>”. #include <stdio.h> int main(){ //initialize 10 int single dimension array int array[10], temp, i, x, y; //promt user for input and store it in the array printf(“Enter 10 Whole Numbers: “); for (i = 0; i < 10; i++){ scanf(“%d”, &array[i]); } printf(“Unsorted Values: \n”); //print current values in array for (i = 0; i < 10; i++){ printf(“Value in index [%d] = %d\n”, i, array[i]); } printf(“\n”); printf(“Sorted Values: \n”); //sort array for (x = 0; x < 10; x++){ for (y = x + 1; y < 10; y++){ if (array[x] > array[y]){ temp = array[x]; array[y] = array[x]; array[y] = temp; } } } //print sorted values for (i = 0; i < 10; i++){ printf(“Value in index [%d] = %d\n”, i, array[i]); } }