Question: Working in C, modify the code below to add each term into a numeric array. Be sure to allocate sufficient space for the array ahead

Working in C, modify the code below to add each term into a numeric array. Be sure to allocate sufficient space for the array ahead of time. How do you know how much space is sufficient? Next, write a function that updates the array by deleting all of the values in odd-numbered slots. For each deleted value, all of the terms afterward will need to be shifted over. After the function call, have the main program print the updated array. Does your program print the correct number of terms?

Code:

//main.c

#include

#include

int main()

{

//declare a integer data type variales

int first;

int second;

int result=0;

//Set INT_MAX as max value

int max=INT_MAX;

printf("Enter first value :");

scanf("%d",&first);

printf("Enter second value :");

scanf("%d",&second);

printf("%d,",first);

printf("%d,",second);

//Add the two values and store sum in result variable

result=first+second;

/*Loop till result is less than max value*/

while(result<=20000)

{

//print result value

printf("%d,",result);

//Assign second value to first

first=second;

//Assign the result to second

second=result;

//Add two values and assign sum to result

result=first+second;

//Break the loop if result is less than 0

if(result<0)

break;

}

return 0;

}

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!