01 #include <stdio.h> |
The first thing that we notice about
the new source code is that it is considerably larger than our previous program.
The added overhead is necessary to define and maintain all of the components of
the window. In a shell program these things are handled by the operating system,
but here we must take control.| Type | Size (in bytes) | Minimum Value | Maximum Value |
|---|---|---|---|
| char | 1 | -128 | +127 |
| unsigned char | 1 | 0 | +255 |
| signed char | 1 | -128 | +127 |
| int | 2 | -32,768 | +32,767 |
| unsigned int |
2 |
0 |
+65,535 |
| signed int |
2 |
-32,768 |
+32,767 |
| short int |
2 |
-32,768 |
+32,767 |
| unsigned short int |
2 |
0 |
+65,535 |
| signed short int |
2 |
-32,768 |
+32,767 |
| long int |
4 |
-2,147,483,648 |
+2,147,483,647 |
| signed long int | 4 | -2,147,483,648 | +2,147,483,647 |
| unsigned long int |
4 |
0 |
+4,294,967,295 |
| Type | Size (in bytes) | Minimum Value | Maximum Value |
|---|---|---|---|
| float | 4 | 3.4e-38 | 3.4e+38 |
| double | 8 | 1.7e-308 | 1.7e+308 |
| int
MyFirstVariable;
/* 2 byte integer */ char _my_1st_little_char_; /* 1 byte integer */ unsigned long int _2Million = 2000000; /* 4 byte integer, initial value 2000000 */ float FloatingPoint; /* 4 byte decimal */ double BigNumber = 1.8e45; /* 8 byte decimal, initial value 1.8 * e^45 */ |
| #include
<stdio.h> int main(void) { /* Declare Var1 as a two byte integer with a value of 10. */ int Var1 = 10; printf( "value = %d\n", Var1 ); /* Value of Var1, will be 10. */ printf( "address = %d\n", &Var1 ); /* Address of Var1, will likely not be 10. */ } |
| #include
<stdio.h> int main(void) { int MyVariable = 10; /* Initialize MyVariable to 10. */ int Value = 0; /* Initialize Value to 0. */ int *MyPointer; /* Reserve some space to hold an address of an integer. */ MyPointer = &MyVariable; /* Copy the address of MyVariable into MyPointer. */ Value = *MyPointer; /* Use indirection to obtain the value of the variable pointed to by MyPointer (the value of MyVariable). */ printf( "Value = %d\n", Value ); /* Print the value of Value. It will be 10. */ } |
| struct
Auto { unsigned int Year; /* Year the car was made. */ float Latitude; /* Car's current latitude. */ float Longitude; /* Car's current longitude. */ float Fuel; /* Remaining fuel in liters. */ float Weight; /* Car's weight in kilograms. */ char Passengers; /* Current number of passengers. */ }; |
|
struct Position { float Latitude; /* latitude. */ float Longitude; /* longitude. */ }; struct Auto { unsigned int Year; /* Year the car was made. */ struct Position Location; /* Lat & Long location of car. */ float Fuel; /* Remaining fuel in liters. */ float Weight; /* Car's weight in kilograms. */ char Passengers; /* Current number of passengers. */ }; |
| struct Auto Car1; |
| float
RemainingFuel; char Occupants; Car1.Year = 1995; RemainingFuel = Car1.Fuel; Car1.Weight = 900.0; Occupants = Car1.Passengers; Car1.Location.Longitude = 0.5; Car1.Location.Latitude = 51.32; |
| struct
Auto *pCar1; pCar1->Year = 1938; pCar1->Occupants = 4; pCar1->Location.Longitude = 0.5; pCar1->Location.Latitude = 51.32; |
| Value Test | Example | English |
|---|---|---|
| == | A == B | If A equals B then... |
| != | A != B | If A is not equal to B then... |
| > | A > B | If A is greater than B then... |
| < | A < B | If A is less than B then... |
| >= | A >= B | If A is greater than or equal to B then... |
| <= | A <= B | If A is less than or equal to B then... |
| Boolean Test | Example | English |
| && | A && B | If A and B are both true then... |
| || | A || B | If either A or B are true then... |
| ! | !A | If A is not true then... |
| if ( IntuitionBase ) |
| 01 void
MyFunction(int A) 02 { /* Begin a new block, call it block X. */ 03 int B = 10; 04 05 if (A == B) 06 { /* Begin a second block, call it block Y. */ 07 int C; 08 09 C = A * B; 10 } /* End the second block. C is out of scope, A and B are still in scope. */ 11 12 A = C + 2; /* This line will generate a compiler error because C is out of scope. */ 13 14 } /* End the first block. A and B are now out of scope. */ |
Last updated on
Saturday, February 11, 2006 19:34