int main(int argc, char **argv) { char *queryp; int bool_balance; sanitize_input(&argc, argv); if (argv[1][0] == 's') { print_summary(argv[2]); exit(0); } mysql_start(); bool_balance = check_balance(&argc, argv); queryp = forge_query(&argc, argv); mysql_insert(queryp); if (bool_balance) calculate_balance(&argc, argv); mysql_stop(); return 0; }
void retirement (int startAge, double initial, retire_info working, retire_info retired) { int i; double working_account = initial; for (i = startAge; i < startAge + working.months; i++ ) { printf("Age %3d month %2d you have $%.2lf\n", i/12, i%12, working_account); working_account = calculate_balance(working.regular_change, working.rate_of_returns,working_account); } int j; double retired_account = working_account; for (j = startAge + working.months; j < startAge + working.months + retired.months; j++ ) { printf("Age %3d month %2d you have $%.2lf\n", j/12, j%12, retired_account); retired_account = calculate_balance(retired.regular_change, retired.rate_of_returns, retired_account); } }
int main() { init_motors(); init_peripherals(); // find out how many cells are connected u16 batteryCutoff; while((batteryCutoff = getBatteryVoltage()) == 0); if(batteryCutoff > 720) // voltage is higher than 6V -> 2cells batteryCutoff = 720; // cutoff 6V else batteryCutoff = 360; // cutoff 3V calibrate_sensors(); // enable interrupt driven gyro acquisation startGyro(); u08 c = 0, maxThrust = (batteryCutoff>360)?70:100; u08 cutBattery = 0; while(1) { if(Thrust > maxThrust) Thrust = maxThrust; calculate_balance(Thrust, Yaw, Pitch, Roll); checkForInput(); // check battery if(((c%100)==0)) { u16 bat = getBatteryVoltage(); if(bat > 0 && bat <= batteryCutoff) { if(maxThrust > 0) maxThrust -= 5; cutBattery = 1; } } if(!cutBattery || !(c % 50)) PORTC ^= (1<<2); c++; //_delay_ms(100); } }