Notes from C Programming for Arduino
#include <stdio.h>
int main() {
/* my first program in C */
printf(“Hello, World! \n”);
return 0;
}
$ gcc -v
$ gcc hello.c
$ ./a.out
Hello, World!
$ gcc -v
$ gcc hello.c
$ ./a.out
Hello, World!
Data Types
Integer: char (1 byte), unsigned char (0 to 255), signed char (-128 to 127)
int (2 or 4 bytes), unsigned int (0 to 65,535 or 0 to 4,294,967,295)
short (2 bytes), unsigned short (0 to 65,535)
long (4 bytes), unsigned long (0 to 4,294,967,295)
Float: float (4 bytes), 1.2E-38 to 3.4E+38 (6 decimal places)
double (8 bytes), 2.3E-308 to 1.7E+308 (15 decimal places)
long double (10 bytes) 3.4E-4932 to 1.1E+4932 (19 decimal places)
void: Function Returns, Function Arguments, Pointers to Void
#include <stdio.h>
#include <limits.h>
#include <float.h>
int main() {
printf(“Storage size for int : %d \n”, sizeof(int));
printf(“Storage size for float : %d \n”, sizeof(float));
printf(“Minimum float positive value: %E\n”, FLT_MIN);
printf(“Maximum float positive value: %E\n”, FLT_MAX);
printf(“Precision value: %d\n”, FLT_DIG);
return 0;
}