Sections of the C Program

  1. Documentation

    • Program Description as Comment

      • // Single-Line Comment
        /* Multi
        Line
        Comment*/
  2. Preprocessor/Link Section

    • Include the Library/Builtin Function Header Files

      • #include<stdio.h>
    • Include the User-Defined Header Files

      • #include<my_header.h>
    • Conditional Compilation

      • #ifndef
        
        #endif
  3. Definition

    • Define Macro Preprocessor

      • #define num 10
  4. Global Declaration

    • Global Variables

      • int num = 10;
    • Global Static Variables

      • static int num = 10;
    • Global Constant Variables

      • const int num = 10;
    • User-Defined Function Declaration/Prototype

      • int is_zero(int);
  5. Main() Function

    • Main Program

      • int main(){
        
            printf("Hello World");
            
            return 0;
        }
  6. Sub Programs

    • User-Defined Function Definition

      • int is_zero(int num){
            if(num==0){
                return 1;
            }
            else{
                return 0;
            }
        }

Last updated