C Language – An Integrated Example (The Five Grammatical Elements of a Programming Language)
1. Integrated Example The following example is a comprehensive example that uses all five grammar elements of the C programming language (variables, operators, statements, control, and functions) and includes all 32 reserved keywords and 12 preprocessor directives under the C90 standard in a single compilable source file. from C Language - Programming Language Grammar exam.c /* * exam.c - Comprehensive C grammar example * */ // #include - include C headers #include <stdio.h> #include <stdlib.h> // #define - define macro #define MAX_COUNT 5 #define BUF_SIZE 64 #define DEBUG_LEVEL 0 // #undef - undefine macro #undef DEBUG_LEVEL #define DEBUG_LEVEL 1 // #ifndef / #endif - compile only if macro is not defined #ifndef RELEASE #define RELEASE #endif // #if / #elif / #else / #endif - conditional compilation #if DEBUG_LEVEL == 0 #define BUILD_TYPE "Release" #elif DEBUG_LEVEL == 1 #define BUILD_TYPE "Debug" ...