High School Mathematics Extensions/Mathematical Programming/Output Routines

From Wikibooks, open books for an open world
< High School Mathematics Extensions‎ | Mathematical Programming
Jump to: navigation, search
High School Mathematics Extensions75% developed

Supplementary Chapters50% developedPrimes and Modular Arithmetic100% developedLogic75% developed

Mathematical Proofs75% developedSet Theory and Infinite Processes50% developed Counting and Generating Functions75% developedDiscrete Probability25% developed

Matrices100% developedFurther Modular Arithmetic50% developedMathematical Programming0% developed


Two new global variables were added: double x_val and double delta.

Two new functions were added: void output() and double process().

One function was changed: void execute_command(char command).

Global Variables

double x_val: the value for x that is passed to f(x).

double delta: the value by which x is changed when the + or - commands are executed.

Function Additions

void output()

  • This function calls process to get the value of f(x) and then prints the message f(x)=value.

double process()

  • Executes the C implementation for f(x).

Function Changes

void execute_command(char command)

  • Called the new function output to display f(x)=value.
  • Implements the '-' and '+' commands for the variables x_val and delta.

Code to change[edit]

Crystal Clear action apply.png Add and replace the following code:
 //function prototypes
 float process();
 void output();

 //global variables
 float x_val;
 float delta;

 //function definitions
 void execute_command(char command)
    switch (command)
        case '=':   output();
        case '+':   output();
        case '-':   output();
        case 'd':
        case 'D':   break;
        case 'x':
        case 'X':   done++;
float process()
    return x_val * x_val;
void output()
    float f_val;


Next Step[edit]