Programming Class

  • rss
  • Home

Strings

1) Strings

[ Up ] [ Next ]

Computers are sophisticated calculators, and deal exclusively with numbers (digits).  In order to get them to cope with other types of information, we have to encode that information in a numerical (digital) way.  Let’s say that we give every letter of the alphabet a unique number, for example:

1 2 3 4 5 6 7 8 9 10 11 12 13
A B C D E F G H I J K L M
14 15 16 17 18 19 20 21 22 23 24 25 26
N O P Q R S T U V W X Y Z

While we’re at it, we should give all the symbols we would possibly want to use a number:

27 28 29 30 31 32 33 34 35 36
! “ £ $ % ^ & * ( )

And if we want to represent numbers themselves as text rather than their numerical value, we should give each of the numbers a number:

37 38 39 40 41 42 43 44 45 46
0 1 2 3 4 5 6 7 8 9

Letters, symbols, and numbers collectively are known as characters.  A set  deciding which character gets which number is known as a character encoding.  Clearly, if we want to copy and paste text from one program to another, or just send an email, everyone needs to agree on which character encoding to use.  Two of the most popular character encodings are known as ASCII and Unicode.

Characters on their own are not as much use as lists of characters.  When we put characters together side by side we can make words, sentences, or entire books.

8 5 12 12 15 27
H E L L O !

A list of characters is known as a string.  To tell the compiler we want to specify a string, we use a pair of  ” symbols.  Everything between the ” symbols will be encoded by the compiler as a list of characters, for example:

"Hello"

The string must all be on one line however, and we can’t use the ” character inside a string or the compiler will get confused about where the string ends, and the rest of the program begins.

Tasks:

  • Compile and run the program to see what happens
  • Replace the characters inside the “ symbols with your own name, and compile and run again.
Comments
No Comments »
Categories
Uncategorized
Comments rss Comments rss
Trackback Trackback

Beginners

The beginners programming tutorial is split into three sections:

Part 1

Covers the very basics of programming:

  • likely errors
  • code flow
  • decisions
  • looping
  • comments

Part 2

More advanced fundamentals:

  • strings
  • arithmetic
  • functions
  • variables
  • imports

Part 3

A closer look at the more popular general purpose languages, and where to go from there.

  • summary
  • software available
  • books available
Comments
No Comments »
Categories
News, Uncategorized
Comments rss Comments rss
Trackback Trackback

Blogroll

  • COD 5
  • Dell Inspiron Chargers
  • Door Handles
  • Kiosks
  • Laptops

Tags

Broadband Managed Hosting mobile broadband solar heating solar lighting Telephone Systems wireless broadband

Categories

  • Broadband
  • Hosting
  • News
  • Telephone Systems
  • Uncategorized

Pages

  • About
  • Access Ramps
  • Automotive Class
    • Driving Training
    • Environmental
  • Business Class
    • Online marketing
    • Website Design
  • Cosmetic Surgery Info
  • Financial Class
  • Health Class
  • Leisure Class
    • Beauty/Spas
  • Oral Care
  • Other Class
  • Promotional Videos
  • Property Class
  • Services Class
    • 08 numbers
    • Roofing
  • Shopping Class
  • Small business phone systems
  • Technology Class
    • Laptops
Content provided by Custard Media