balloon c code

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>

int main (void)

{
//Define variables

double alt = 0 ;
double v = 0 ;
double startt = 0 ;
double endt = 0 ;
double t = startt ;
double inct = 0 ;
double t_max = 0;
double alt_max = 0;

//Print title

printf(" Balloon Information \n") ;
for(t = 60; t < 2880; t++) // Convert hours to minutes
{
//Tell and allow the user to input the start time

printf("Enter start time = ");
scanf("%lf", &startt);

//Tell and allow the user to input the end time
printf("Enter endtime = ");
scanf("%lf", &endt);

//Tell and allow the user to input the increment between line for time
printf("Enter Line Increment of Time = ");
scanf("%lf", &inct);

//Print table
printf(" Altitude Velocity \n");


//Find the balloon information for every 10 minutes and print
for (t = startt; t<= endt; t = t + inct)
{
if(startt >= 2881 && endt >= 2881 )
{
printf("warning!!! enter valid numbers \n");
}

alt = ((-0.12*(pow(t,4)) + (12*(pow(t,3))) - (380*(t*t)) + (4100*t) + 220));
v = ((-0.48*(pow(t,3)) + (36*(t*t)) - (760*t) + 4100));
printf(" %5.2lf m %5.2lf mps \n", alt, v/3600);

//print peak altitude and time

/* if (alt >alt_max)
{
printf(" Peak Altitude \n");
printf(" Peak Time \n");
alt_max = alt;
t_max = t;
printf(" %5.2lf m \n", alt_max);
printf(" %5.2lf s \n", t_max);
} */

} //Close out second while loop


} //Close out first while loop

//Exit program
system("pause");
return (0);
}


Comments

Popular posts from this blog

pointers code no lb

real time & EEPROM lab

interrup and sound lab