I have a one-dimensional array where I need to replace the array elements after the smallest element with one, but I don't know what I need to write to make this condition work? I will be grateful for your help.
#include <stdio.h>
#include <stdlib.h>
void main() {
float X[16] = {2.34, -3.42, 0.56, -3.71, 1.25, 6.37, 0.123, -45.821,
32.5, 0.94, 0.54, -1.26, 2.36, 4.32, -5.345, 4.876};
float sum;
float min;
float Y[16];
printf("Massiv Х\n");
for (int i = 0; i < 16; i++) {
printf("%2.3f\t", X[i]);
}
for (int i = 0; i < 16; i++) {
if (min > X[i]) {
min = X[i];
}
}
printf("\nMin= %2.3f", min);
printf("\nMassiv \n");
X[16] = 1;
for (int i = 0; i < 16; i++) {
printf("%2.3f\t", X[i]);
}
sum = 0;
for (int i = 0; i < 7; ++i) {
if (X[i]) {
sum += X[i];
}
}
printf("\nSum= %2.3f\t", sum);
}