{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

HW3_ruzmora

HW3_ruzmora - Chapter 3 Problem 30 This program will...

This preview shows pages 1–3. Sign up to view the full content.

Sheet1 Page 1 /* Chapter 3 Problem 30 */ /* This program will determine the time at which a rocket descends back to Earth*/ #include <stdio.h> #define FILENAME "rocket1.txt" int main(void) { /*Declare and initialize variables */ FILE *rocket1 int ndpts int k double time,prev_time, current_time, now_altitude, velocity, acceleration, prev_altitude rocket1 = fopen(FILENAME, "r") if (rocket1 == NULL) { printf("Error opening input file \n") } else { fscanf(rocket1, "%d", &ndpts) fscanf(rocket1, "%lf %lf %lf %lf", &time, &now_altitude, &velocity, &acceleration) prev_altitude = now_altitude prev_time = time for (k = 0 k < (ndpts - 1) { fscanf(rocket1, "%lf %lf %lf %lf", &time, &now_altitude, &velocity, &acceleration) if (now_altitude < prev_altitude) { if (prev_time < time) { current_time = prev_time break } } prev_time = time prev_altitude = now_altitude } printf("The rocket starts to descend at:%6.2f\n", current_time) fclose(rocket1) } /*Pause program */ getchar() getchar() g /* Exit program */ return 0 }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Sheet1 Page 2 /* Chapter 3 Problem 31 */ /* This program will determine the number of stages of a rocket*/ #include <stdio.h> int main(void) {
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern