Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write C code for the following: The altitude (ft) from the sea level and the cor

ID: 3817548 • Letter: W

Question

Write C code for the following: The altitude (ft) from the sea level and the corresponding time (sec) for a fictitious rocket were measured as follows: Numerically compute the velocity from the table above using the central difference scheme. Use equation (1)at t = 0 and equation (2) at t = 200. f'(x) = 4f(x+h) - f(x+2h)-3f(x)/2h (Eq.1) f'(x) = 3f(x)-4f(x-h)+f(x-2h)/2h (Eq.2) Make sure that you attach example runs showing the results from the computer. For the value of x is time and the value of his height

Explanation / Answer

#include<stdio.h>
//for time equals 0 using equation 1
double f1(long int h[])
{
   double v;
   v = 4*h[1]-h[2]-3*h[0];
   v=v/(2*h[0]);
   return v;
}
//for time =200// using equation 2
double f2(long int h[])
{
   double v;
   v=3*h[10]-4*h[9]+h[8];
   v=v/(2*h[10]);
   return v;
}
//for remaing time values.
double f(int x,long int t[],long int h[])
{
   double v;
   v = h[x+1]-h[x-1];
   v =v/(t[x+1]-t[x-1]);
   return v;
}


int main()
{
   //array declarations
   long int time[]={0,20,40,60,80,100,120,140,160,180,200};
   long int altitude[]={370,9170,23835,45624,62065,87368,97355,103422,127892,149626,160095};
  
   double vel[10];
  
  
  
   //calculating velocities..using central difference scheme...
   int x;
   for(x=0;x<11;x++)
   {
       printf("Time :%ld ",time[x]);
       printf("Altitude : %ld ",altitude[x]);  
       if(time[x]==0)
       {
           printf("Result : %lf ",f1(altitude));
       }
       else if(time[x]==200)
       {
           printf("Result : %lf ",f2(altitude));  
       }
       else
       {
           printf("Result : %lf ",f(x,time,altitude));  
       }  
   }
  
  
  
  
  
  
  
   return 0;
}

output:-

Time :0
Altitude : 370
Result : 15.858108
Time :20
Altitude : 9170
Result : 586.625000
Time :40
Altitude : 23835
Result : 911.350000
Time :60
Altitude : 45624
Result : 955.750000
Time :80
Altitude : 62065
Result : 1043.600000
Time :100
Altitude : 87368
Result : 882.250000
Time :120
Altitude : 97355
Result : 401.350000
Time :140
Altitude : 103422
Result : 763.425000
Time :160
Altitude : 127892
Result : 1155.100000
Time :180
Altitude : 149626
Result : 805.075000
Time :200
Altitude : 160095
Result : 0.030210


Process exited normally.
Press any key to continue . . .

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote