Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
/* * structure.c — anatomy of a well-structured C file. */ #include <stdio.h> /* printf, scanf */ #include <stdlib.h> /* EXIT_SUCCESS, EXIT_FAILURE */ /* --- Constants defined at the top --- */ #define MAX_ITEMS 100 #define PROGRAM_VERSION "1.0" /* --- Function prototype (declaration before use) --- */ void print_banner(const char *version); /* --- main: program entry point --- */ int main(void) { print_banner(PROGRAM_VERSION); int count = 0; printf("Enter a number (0 to quit): "); while (scanf("%d", &count) == 1 && count != 0) { printf("You entered: %d ", count); } return EXIT_SUCCESS; } /* --- Function definition --- */ void print_banner(const char *version) { printf("=== My C Program v%s === ", version); }
Result
Open