LOGBOOK

HELP

Quiz Entry - updated: 2026.06.23

What is the general structure of a C program?

Top to bottom: #include directives, #define macros, global variables, then function definitions — with main() as the entry point.

// Include files (headers)
#include <stdio.h>

// Preprocessor defines
#define LIMIT 50

// Global variables
int A = 0;
const int B = 1;

// Function definitions
int fib(int n)
{
    if (n > 1) return fib(n-1)+fib(n-2);
    else return 1;
}

// Entry point
int main(int argc, char *argv[])
{
    // Local variables
    int n = argc;

    printf("Hello, world!\n");
    printf("Fib(%d) = %d\n", n, fib(n));

    // Exit code (0 = success)
    return 0;
}

Order matters:

  • #include and #define must come first (preprocessor)
  • Functions must be declared before use (or use forward declarations)
  • main() is the entry point - execution starts here

Tip: Use https://godbolt.org/ to see how each part compiles to assembly!

From Quiz: REVE1 / C Programming | Updated: Jun 23, 2026