Question: Write this c program Create an array of 10 ints called myArray. Give the array contents an initial value of 0in the variable declaration. Create
Write this c program Create an array of 10 ints called myArray. Give the array contents an initial value of 0in the variable declaration. Create a loopto prompt the user and get revised values(using getNum)for all of the array elements, pressing ENTER after each of the 10 items. Within the loop, keep track of which element has the lowest value. After the loop is done,display the minimum element's index and value.Do not create any other functions besides getNum.You can assume that the user will always enter valid input. #pragma warning(disable: 4996) int getNum(void) { /* the array is 121 bytes in size; we'll see in a later lecture how we can improve this code */ char record[121] = { 0 }; /* record stores the string */ int number = 0; /* NOTE to student: indent and brace this function consistent with your others */ /* use fgets() to get a string from the keyboard */ fgets(record, 121, stdin); /* extract the number from the string; sscanf() returns a number * corresponding with the number of items it found in the string */ if (sscanf(record, "%d", &number) != 1) { /* if the user did not enter a number recognizable by * the system, set number to -1 */ number = -1; } return number; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
