Computer Science GRE Study Guide, Data types

Table of Contents

I.    Software Systems and Methodology – 40%

A.    Data organization

1.      Data types

a.       Definition: Data types are assigned to blocks of information. The type tells the program how to handle the specific information. For example, an integer data type can be multiplied, but a Boolean data type cannot.

b.      In C, we have a data type called a struct that allows us to create records with fields. Declare a struct variable using the form
struct node { int age;
char gender;}
To access a field in the record use the form “node->age;”.

c.       A pointer is an unusual type. The value that it holds is a memory address. We then use the memory address to manipulate the data held at that memory address. In Pascal, to declare a pointer use:
type Link = ­type-name;
If you want to manipulate the memory address, then use the ­ before the variable name. For example, ­H means, “points to H”. If you want to manipulate the data, then use the ­ after the variable name. So, H­ means “H points at this data”. Remember that we read English left to right; this might help you remember what the ­ operator does in which position. In C, to declare a pointer, use the * operator: int *p;. To store the address of a variable v in the pointer p use the statement p = &v; The ampersand (&) is the operator that returns the address instead of the value. Finally, to store a value in the pointer use the * operator again; for example, *p = v; will store the value of v at the location of p.

⇒ Next section

Liked it? Take a second to support Hunter Hogan on Patreon!
Become a patron at Patreon!

I’m disabled & homeless.

I must earn money from advertisements.

Please whitelist my website and YouTube channel in your ad blocker or cookie blocker, such as Privacy Badger.

Thank you.