Chapter 3

Manipulating Data

IN THIS CHAPTER

Bullet Using assignment and math operators

Bullet Understanding string manipulation

Bullet Using comparison and Boolean operators

Bullet Performing data type conversions

Every program accepts data from the outside world, manipulates that data in some way, and then calculates a useful result. Data can be

  • Numbers
  • Text
  • Input from a keyboard, mouse, 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 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 operators (built-in commands) 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 ...

Get Beginning Programming All-in-One For Dummies, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.