15.01.2024 Views

CompTIA A+ Certification All-in-One Exam Guide

  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

A way to think of a string is as a sequence of characters, like c – o – w.

Most programming languages require that you identify a string with ‘single’

or “double” quotes, so ‘cow’ or “cow” in this example. While only some

characters are valid integers, all characters can be valid in a string. Every

programming language dictates actions that the computer can perform on

strings (like joining two strings together, breaking one string into pieces,

checking how many characters are in a string, and so on). While arithmetic

dictates that you can’t add 3 + cow (probably because it would upset the

cow), you can combine “brown” + “cow” and create a “brown cow” (and

have a happier cow).

EXAM TIP The CompTIA A+ objectives mention only two basic data

types—strings and integers. Some languages have additional data types for

more specific circumstances (like a special type for dates, or fractional

numbers), but you won’t need to know them for the exam.

Here’s the next cool concept. Numbers are characters too, just like words.

Numbers, therefore, can show up in strings—and programming languages

have to treat number characters differently when quoted or not quoted. A

programming language determines what to do with a telephone number

without quotes and with quotes, for example, like these:

In the first case, a computer wouldn’t have any choice but to compute the

result of 281 minus 922 minus 4166, which results in –4807 (an integer data

type). In the second case, a computer would keep intact a string containing

the phone number to my office. Yes, our refrigerator is running.

Variables

As soon as the computer thinks it’s done with this value (whether it’s –4807

or “281-922-4166”), it will forget it. If you need to use it more than once, you

have to tell the computer to save it. Most programming languages tell the

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

Saved successfully!

Ooh no, something went wrong!