Question: I need help editing this code to delete the odd-numbered slots in the array. I cannot seem to get it. I have a function set

I need help editing this code to delete the odd-numbered slots in the array. I cannot seem to get it. I have a function set to remove a specific term in the array but I need to delete all odd values. Thank you for your help

To be more specific in the lines

//Create a function for array to be pased too void array_function(float* arrayname, int arraysize, int remove2) { //define variables int i = 0; for (i = remove2; i < arraysize; i++) { arrayname[i] = arrayname[i / 2]; } //display the array

for (i = 0; i < arraysize - 1; i++) { printf(" This is the %d term of the array: %.2f", i, arrayname[i]); }

Rather than removing just one term from the array I need to print each odd term from the array

Here is the code:

#include //add function prototype void array_function(float* arrayname, int arraysize, int remove2); int main() { float a = 0, b = 0, sum = 0; int n = 0, i = 0, remove = 0; float termarray[101]; printf("Input two integers to begin the Fibonacci Sequence "); //input first value for program printf("Value 1:"); scanf_s("%f", &a); //input second value for program printf("Value 2:"); scanf_s("%f", &b);

//input nth term printf(" Input nth value (stopping value 0-100):"); scanf_s("%d", &n);

//define loop to execute n times for (i = 0; i <= n; i++) { //Define the sum sum = a + b; printf(" The fibbonacci sequence is %d with a sum of %.2f",i, sum); //set A=b a = b; b = sum; termarray[i] = sum; } //Ask which array value to remove

printf(" Which element should we delete?:"); scanf_s("%d", &remove); array_function(termarray, n, remove); }

//Create a function for array to be pased too void array_function(float* arrayname, int arraysize, int remove2) { //define variables int i = 0; for (i = remove2; i < arraysize; i++) { arrayname[i] = arrayname[i / 2]; } //display the array

for (i = 0; i < arraysize - 1; i++) { printf(" This is the %d term of the array: %.2f", i, arrayname[i]); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!