SOLENT UNIVERSITY
t = n[j];
n[j] = n[j + 1];
n[j + 1] = t;}
}
}
if (i % 2 == 0) {
m = (n[i / 2] + n[(i - 1) / 2]) / 2.0;
} else
m = n[i / 2];
printf("The array elements rearrange by numerical order are:\n");
for (i = 0; n[i] != term; i++)
printf("%d\t", n[i]);
printf("\nThe median value in the array is: \n%.1f", m); } else if (choice == 'x' || choice == 'X') {
return;
} else
printf("\nWrong input, sorry.");
}
}
printf("Please enter 1 to 30 elements only.");
}
In figures 71,72,73,74,75 and 76 the program is running properly with getchar();. All the menu is inside a
while loop, that it run as true condition ( no equal to EOF, end-of-file) till the user enter the character x or X
(return;).
Fig71-Task5-GradeA
56
, SOLENT UNIVERSITY
Fig72-Task5-GradeA
Fig73-Task5-GradeA
Fig74-Task5-GradeA
57
t = n[j];
n[j] = n[j + 1];
n[j + 1] = t;}
}
}
if (i % 2 == 0) {
m = (n[i / 2] + n[(i - 1) / 2]) / 2.0;
} else
m = n[i / 2];
printf("The array elements rearrange by numerical order are:\n");
for (i = 0; n[i] != term; i++)
printf("%d\t", n[i]);
printf("\nThe median value in the array is: \n%.1f", m); } else if (choice == 'x' || choice == 'X') {
return;
} else
printf("\nWrong input, sorry.");
}
}
printf("Please enter 1 to 30 elements only.");
}
In figures 71,72,73,74,75 and 76 the program is running properly with getchar();. All the menu is inside a
while loop, that it run as true condition ( no equal to EOF, end-of-file) till the user enter the character x or X
(return;).
Fig71-Task5-GradeA
56
, SOLENT UNIVERSITY
Fig72-Task5-GradeA
Fig73-Task5-GradeA
Fig74-Task5-GradeA
57