ANSWERS WITH COMPLETE SOLUTIONS VERIFIED
A data type is...
- a set of possible values
- a set of possible operations on these values
- a representation of these values for a specific machine
four basic types
- char
- int
- float
- double
modifiers
used to modify the length or size of data
What are the four derived types in C?
Pointers, arrays, structs, unions
What is the purpose of pointers in C?
To hold the address of entities of some type
Give an example of a pointer declaration in C
char* cptr
(cptr holds the address)
How are structs used in C?
, To group together things of possibly different types
array format
char cArray[n+1]
pointer arithmetic
addresses are integers
i.e. &b + 3
char can range only from
-128 to 127
long can range from
-2,147,483,648 to 2,147,483,647
C does not have a boolean type. How would you define it?
#define BOOL char
#define FALSE 0
#define TRUE 1
int range
-2,147,483,648 to 2,147,483,647
(used for numbers)
most common directive
#include <stdio.h>
int main() { ... }
will return an integer - if our code ran successfully, 0.
- # > 0 means that the program failed