-
Notifications
You must be signed in to change notification settings - Fork 0
/
defines.c
29 lines (21 loc) · 884 Bytes
/
defines.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
#include "defines.h"
/* nonstandard includes are quoted instead of using angle
* brackets. Those header files are expected to be found
* in the working directory where the compilation happens
* you may include headers in subdirs as well.
*/
int globalVariable = 10; // globals must be assigned at declaration
// assigning is often referred to as initialization when done first time
int main()
{
int declaredLocal; // only local variables can be declared empty
declaredLocal = 5;
printf("PI, imported from defines.h: %.2f\n\
globalVariable, accessed by all funcs: %d\n\
another way to assign vars is declare in a \n\
line then assign in another. Like declaredLocal: %d\n", PI, globalVariable, declaredLocal);
int x = 5/2.0; // type int to float will discard any fractions
printf("%.2f\n",(float) x); // (type) casting
return 0;
}