Friday 21 November 2014

Benefits Of Data Types (Unit 06)

There are many different data types that are available for programmers to use and I will explain and give examples of why some of these data types are useful to programmers.

String - This is a very useful data type as it can hold multiple characters without having to use the data type char for every character, when using the data type String you must use quotation marks.

String sName=”Bob”;  <----- The string is Bob

Integer - This is one of the most commonly used data types, the definition of an integer is a whole number. Using integers in programming can prove to be useful when writing programs as a lot of programs are used to perform mathematical sums.

int iAge=10; <---- The integer is 10

Char - This data type holds a single character, this can be used if you want to search for single characters rather than a sequence of characters creating a string. When using char you must use quotation marks.

char cFirstLetter=”B”; <---- The char is B

Double -  This data type is normally the default choice for decimal values. This means it is similar to the integer data type however it has a decimal afterwards.

double dDecimalNumber=10.53;

Boolean - This data type can be used for creating a true or false statement as those are the two values a boolean can have. This tracks true/false conditions and represents one bit of information.

boolean b1 = true

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home