If the array element is twice as large as its predecessor (for example 1,2,3,4,.. in this case element 2 is twice as large as element before 2, which is 1) then program should make average value of these two elements (in this case 1 + 2 = 3, 3/2 = 1.5) and after making average value, program should put that value between these two numbers and print new array. (in this case new array would look like: 1, 1.5, 2, 3, 4, ...) Do you have any idea how to make this? Array consists of double numbers.
#include <math.h>
#include <stdio.h>
#define epsilon 0.0001
int main() {
int i, k = 0, n;
double arr[100];
do {
printf("Enter number of array elements: ");
scanf("%d", &n);
} while (n <= 0 || n > 100);
printf("Enter array: ");
for (i = 0; i < n; i++) {
scanf("%lf", &arr[i]);
}
for (i = 0; i < n; i++) {
if (fabs(arr[i + 1] - 2 * arr[i]) < epsilon) {
}
}
return 0;
}