This folder is a personal collection of small C programs used to learn and practice C programming concepts in 2025.
Below are the main source files and folders in this repository (top-level files):
ArrayExercise.c
— small exercises using arraysArrays.c
— array examplesArraysLoop.c
— iterating arrays with loopsArraysSumAndAverage.c
— compute sum and average of array elementsCalculatorVersion2.c
— simple calculator exampleCopyofpassword.c
— password-related example (copy)doWhile.c
— example using do-while loopEvenNumberPrinter.c
— prints even numbersEvenorOdd.c
— checks even or oddforloop.c
— up and down counting examples (fixed)forloop.out
— compiled binary forforloop.c
Functional Calculator.c
— calculator demonstrating functionsFunctions.c
— examples of functionsHello.c
— simple hello worldHello
— (possibly an output folder or alternate file)PasswordAttemptGames.c
— password attempt / game examplePointers.c
— examples using pointersPrintName.c
— prints a name to stdoutSimpleCalculator.c
— another calculator exampleSimpleLoginSystem.c
— very small login system demoStrings.c
— string handling examplesSum of natural numbers.c
— sum of first N natural numbersswicth.c
— switch-case example (note spelling)TemperatureConverter.c
— converts temperatures between unitsUsingScan.c
— examples using scanfVariables.c
— variable exampleswhileLoop.c
— while loop examplesum
— (likely a small program or output)output/
— directory containing compiled outputs or sample outputs
You can compile any single C source file with gcc
. Example (compile forloop.c
):
gcc -Wall -Wextra -std=c11 -o forloop.out "forloop.c"
Then run it:
./forloop.out
To compile many files quickly you can run a loop from the repository root:
for f in *.c; do gcc -Wall -Wextra -std=c11 -o "${f%.c}.out" "$f" 2>/dev/null && echo "built: ${f%.c}.out"; done
- Filenames contain some spaces (e.g.,
Sum of natural numbers.c
,Functional Calculator.c
) — these work but are harder to manage in scripts; consider renaming them to use underscores or dashes. - Some filenames have typos (
swicth.c
) — you may want to correct them if you use them frequently. - Many example programs are self-contained; open each
.c
to see comments and how the example is structured. - If you want, I can:
- Add a
Makefile
to build common examples quickly, - Normalize file names to a consistent style,
- Run and capture outputs for each program and place them in
output/
.
- Add a
This folder contains learning code. Add a license file if you plan to share it publicly.
If you'd like, tell me how you'd like the README formatted (short list, detailed docs per file, or add a Makefile) and I'll update it accordingly.
Commit: 9789b21 — "Reorganize repository: group examples into lessons/, move binaries to builds/, docs to docs/" Author: FMB237 Date: Thu Oct 16 12:48:06 2025 +0100
Files moved: multiple files were reorganized into lessons/
subfolders and build artifacts moved to builds/
(see commit details in git history).
Compile summary (fresh run using gcc -Wall -Wextra -std=c11
)
OK: many lesson examples compiled successfully. The following files produced warnings/errors that you may want to fix:
lessons/01_basics/Variables.c
— useschar grade = "C";
(string literal assigned to char). Usechar grade = 'C';
orchar *grade = "C";
.lessons/04_pointers/PointersAndFunctions.c
— a non-void function does not return on all paths; ensure all paths return a value or change signature tovoid
.lessons/04_pointers/PointersExercise.c
— has unused pointer variables (pa
,pb
) shown by compiler warnings.lessons/08_projects/SimpleLoginSystem.c
—scanf("%s", &Trier);
passes&Trier
(typechar (*)[10]
) instead ofTrier
(typechar *
); usescanf("%9s", Trier);
to avoid overflow.lessons/03_arrays/Arrays.c
— printing an address with%d
(printf("...%d", &score[2]);
) is incorrect; use%p
and cast to(void*)
.
Next recommended fixes:
- Fix the simple issues above and re-run the compile step. I can apply these edits for you.
- Add a top-level
README.md
describing the newlessons/
layout and aMakefile
to build selected examples. - Add a
.gitignore
to avoid committing compiled binaries in future (e.g.,builds/
,*.out
).
If you'd like, I can now apply the simple source fixes (Variables.c, SimpleLoginSystem.c, Arrays.c, and the non-void-return in PointersAndFunctions.c) and re-run compilation.