Chapter II.3. Manipulating Data
Every program accepts data from the outside world, manipulates that data in some way, and then calculates a useful result. Data can be
Input from a keyboard, controller, or joystick (for a video game)
To manipulate numbers, computers can perform a variety of mathematical operations, which is just a fancy way of saying a computer can add, subtract, multiply, and divide. To manipulate text (or strings, as in "text strings"), computers can perform a variety of string manipulation operations, which can chop out a letter of a word or rearrange the letters that make up a word.
Every programming language provides built-in commands (operators) for manipulating numbers and strings, but some programming languages are better at manipulating numbers (or strings) than others.
For example, FORTRAN is specifically designed to make scientific calculations easy, so FORTRAN has more operators for mathematical operations than a language such as SNOBOL, which was designed primarily for manipulating text strings. You can still manipulate strings in FORTRAN or calculate mathematical equations in SNOBOL; however, you need to write a lot more commands to do so.
Programming languages typically provide two types of data manipulation commands:
Operators are usually symbols that represent simple calculations, such as addition (
+) or multiplication (
Functions are commands that perform more sophisticated calculations, such as calculating the square root of a number.