Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

High School Mathematics Extensions/Mathematical Programming/Input Revisited

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Explanation One new functions was added: float get_delta(). One function was changed: void execute_command(char command). Function Additions float get_delta() Prompts for delta. Uses cscanf to guarantee floating point input. Calls getch() function to empty input buffer. Calls cprintf("\n") to move down a line in output. Validates and prints delta. Function Changes void execute_command(char command) Add code to call get_delta for 'd' or 'D' commands. Code to copy The following code is valid: //function prototypes //... float get_delta(); //function definitions //... void execute_command(char command) { //... case 'D': delta=get_delta(); break; //... float get_delta() { float f_val; char lastpress; cprintf("Enter delta: "); cscanf("%f",&f_val); lastpress=getch(); cprintf("\n"); if(f_val < 0.001) { f_val=0.001; cprintf("Delta must be floating point number greater than or equalt to 0.001.\nDelta set to %f.\n",f_val); } else { cprintf("Delta set to %f.\n",f_val); } return f_val; } Next Step ../The Complete Program/