15.04.2018 Views

programming-for-dummies

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 3: Manipulating Data<br />

In This Chapter<br />

Using assignment and math operators<br />

Understanding string manipulation<br />

Using comparison and Boolean operators<br />

Per<strong>for</strong>ming data type conversions<br />

Every program accepts data from the outside world, manipulates that<br />

data in some way, and then calculates a useful result. Data can be<br />

✦ Numbers<br />

✦ Text<br />

✦ Input from a keyboard, controller, or joystick (<strong>for</strong> a video game)<br />

To manipulate numbers, computers can per<strong>for</strong>m a variety of mathematical<br />

operations, which is just a fancy way of saying a computer can add, subtract,<br />

multiply, and divide. To manipulate text (or strings, as in “text strings”),<br />

computers can per<strong>for</strong>m a variety of string manipulation operations, which<br />

can chop out a letter of a word or rearrange the letters that make up a word.<br />

Every <strong>programming</strong> language provides built-in commands (operators) <strong>for</strong><br />

manipulating numbers and strings, but some <strong>programming</strong> languages are<br />

better at manipulating numbers (or strings) than others.<br />

For example, FORTRAN is specifically designed to make scientific calculations<br />

easy, so FORTRAN has more operators <strong>for</strong> mathematical operations<br />

than a language such as SNOBOL, which was designed primarily <strong>for</strong> manipulating<br />

text strings. You can still manipulate strings in FORTRAN or calculate<br />

mathematical equations in SNOBOL; however, you need to write a lot more<br />

commands to do so.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!