/* hello.c Jeff Ondich, 26 April 2019 Part of a quick intro to C At a terminal with the gcc compiler installed, you can compile this program like so: gcc -o hello hello.c and then just run it with: ./hello I generally include the "./" in this command line to avoid the problem where I accidentally name my program the same thing as a system program, and then run the system program instead. "./hello" says "run the command hello that's contained in the current directory." */ #include int main() { printf("Hello, world.\n"); // There are several types of integers. Printing them with // printf looks like this. Note the correspondence between // the types and the %-codes. int a = 5; unsigned int b = 6; long c = 7; unsigned long d = 8; printf("a=%d, b=%u, c=%ld, d=%lu\n", a, b, c, d); // Printing in hexadecimal a = 165; printf("a in hexadecimal = %x\n", a); // The char type represents a single byte. So a char can hold // any ASCII character, but it can't hold any character with // codepoint above 255. char ch = 'Q'; printf("ch = %c\n", ch); // Floating point types. float x = 3.1415926; double y = 2.718281828; printf("x = %f, y = %lf\n", x, y); printf("x with 4 digits past the decimal point = %.4f\n", x); // Why return 0? Because that tells most // Unix command shells that the program completed // without error. return 0; }