Tuesday, February 12, 2008

Input / Output

Why are inputs necessary?

When writing a program, why is inputs needed?
How can inputs be collected?
What is done to the inputs when it is collected?

Who or what give inputs?
Who or what uses inputs?


Why are outputs necessary?

When writing a program, why is outputs needed?
How can outputs be given?
What is done to the outputs when it is given?

Who or what give outputs?
Who or what uses outputs?

2 comments:

mugen said...

Inputs are necessary because the program needs something to work with / manipulate.

Inputs are needed because for example a program can be "hard coded" to find the average of, say, 5 fixed numbers: 3, 5, 12, 10 and 8.

But a more useful program would be one that allows inputs from the user in the form of any 5 numbers of the users choice.

Inputs can be collected by prompting the user to enter one. This value is then stored in a pre-defined space.

This space must be compatible with the input. For example if a decimal is asked of the user, then the space to which this input is saved must be defined as "float" rather than "int".

mugen said...

Outputs are necessary because they show the end result of the program.

When writing a program, outputs are needed to display the computations the program has done.

For example, a program written to calculate the number of tiles needed to tile a floor, will output the number of tiles.

outputs can be given by using the "cout" command.
eg.
cout << " 50 tiles are needed.";