Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions