Posts

Showing posts from January, 2023

C: Convert cm to inches (no function).

Image
Simple program demonstrating conversion of cm to inches without implementing a function. This is simpler, but your ideal implementation may depend upon a variety of factors requiring your careful consideration. Repl: https://replit.com/@pereiradaniel/Convert-cm-to-inches-no-function Git repo: https://github.com/pereiradaniel/c_programs/blob/master/metric_imperial_conv/conv_alt.c  

Vincent - C64 [50Hz]

Image

C: Convert cm to inches using a function.

Image
Simple program demonstrating one way to convert cm to inches and display the result to the user. Repl: https://replit.com/@pereiradaniel/Convert-cm-to-inches-function Git repo: https://github.com/pereiradaniel/c_programs/blob/master/metric_imperial_conv/conv.c  

6510: Colours.

Image
Demonstration of 6510 Assembly program that changes border and background colours in an infinite loop. This video shows how Turbo Macro Pro and the Super Snapshot cartridge can be used with the C64 mini.

Fred's In Troubles - C64 [50Hz]

Image

Fred's Back 3 - C64 [50Hz]

Image

C: Decimal/Binary Converter.

Image
A program that converts decimal and binary numbers. Repl: https://replit.com/@pereiradaniel/Dual-BinaryDecimal-Converter Git repo: https://github.com/pereiradaniel/c_programs/blob/master/bin_dec_conv/dual_conversion/dual_conv.c  

Fred's Back 2 - C64 [50Hz]

Image

C: Decimal to binary conversion with non-recursive function.

Image
Convert a decimal number to binary using a non-recursive function. Repl: https://replit.com/@pereiradaniel/Decimal-to-binary-non-recursive Git repo:  https://github.com/pereiradaniel/c_programs/blob/master/bin_dec_conv/non_recursive/bin_dec_conv.c  

C: Decimal to binary conversion using a recursive function.

Image
Recursive method of decimal to binary conversion. Repl: https://replit.com/@pereiradaniel/Decimal-to-binary-recursive Git repo: https://github.com/pereiradaniel/c_programs/tree/master/bin_dec_conv/recursive  

Fred's Back - C64 [50Hz]

Image

CJs Elephant Antics - C64 [50Hz]

Image

C: Modify calculator to catch divide by zero error.

Image
Calculator now catches divide by zero error by testing to see if either user inputs are equal to 0, otherwise it executes the division. Repl: https://replit.com/@pereiradaniel/Calculator-Exponent-function-added Git repo: https://github.com/pereiradaniel/c_programs/blob/master/calc/calc4.c  

C: Calculator with exponent function.

Image
Added exponent function to calculator, with improved messages for user. Repl: https://replit.com/@pereiradaniel/Calculator-Exponent-function-added Git repo: https://github.com/pereiradaniel/c_programs/blob/master/calc/calc3.c  

The Great Giana Sisters 6, Frankie's Horror Trip 2 - C64 [50Hz]

Image

C: Calculator with main loop repeat.

Image
Calculator program now loops until user quits. Repl: https://replit.com/@pereiradaniel/Calculator-Main-loop-added Git repo: https://github.com/pereiradaniel/c_programs/blob/master/calc/calc2.c  

The Great Giana Sisters 5, Frankie's Horror Trip 1 - C64 [50Hz]

Image

C: Basic calculator program.

Image
Basic calculator program for possible future improvements. Repl: https://replit.com/@pereiradaniel/Calculator-program Git repo: https://github.com/pereiradaniel/c_programs/blob/master/calc/calc.c  

The Great Giana Sisters 4, Power Sisters 1 - C64 [50Hz]

Image

C: Exercise 4-3 improved by splitting ascending/descending loop into two...

Image
Improvement to exercise 4-3 using a different type of switchable for loop, with compiler examination.  Repl: https://replit.com/@pereiradaniel/Improved-asc-desc-for-loop-added-to-existing-project Git repo: https://github.com/pereiradaniel/beginning_c/blob/master/ch4/exercises/4_3/refactor5.c  

The Great Giana Sisters 3, Gitty's Dreams 2 - C64 [50Hz]

Image

C: Improve exercise 4-3 with improved ascending/descending for loop.

Image
Improvement to exercise 4-3 using a different type of switchable for loop, with compiler examination.  Repl: https://replit.com/@pereiradaniel/Improved-asc-desc-for-loop-added-to-existing-project Git repo: https://github.com/pereiradaniel/beginning_c/blob/master/ch4/exercises/4_3/refactor5.c  

The Great Giana Sisters 2, Gitty's Dreams 1 - C64 [50Hz]

Image

C: Improved ascending and descending for loop.

Image
Improved ascending and descending for loop with alternate example and compilation comparison. Repl: https://replit.com/@pereiradaniel/Exercise-4-3-refactor-4 Git repo: https://github.com/pereiradaniel/c_programs/blob/master/asc_desc_for/asc_desc_for2.c  

The Great Giana Sisters - C64 [50Hz]

Image

C: Ascending or descending for loop.

Image
A for loop that can run forward or backward. Repl: https://replit.com/@pereiradaniel/Ascending-or-descending-for-loop Git repo: https://github.com/pereiradaniel/c_programs/blob/master/asc_desc_for/asc_desc_for.c  

H.E.R.O. - C64 [60Hz]

Image

C: Exercise 4-3, sort by ascending or descending order.

Image
Added sorting by ascending or descending order. Repl: https://replit.com/@pereiradaniel/Exercise-4-3-refactor-4 Git repo: https://github.com/pereiradaniel/beginning_c/blob/master/ch4/exercises/4_3/refactor4.c

Boulder Dash 3 - C64 [60Hz]

Image

Boulder Dash 2 - C64 [60Hz]

Image

C: Exercise 4-3 improvements of refactor 3.

Image
Improvement of this program: https://youtu.be/1_ER9Gzsglw Repl: https://replit.com/@pereiradaniel/Exercise-4-3-refactor-3 Git repo (this project):  https://github.com/pereiradaniel/Exercise-4-3-refactor-3 Git repo (archive of projects):  https://github.com/pereiradaniel/beginning_c  

repl: Exercise 4-3, refactor 3.

 

C: Print number of non-printable chars, printable chars, total char code...

Image
Refactor of previous program: https://youtu.be/pILnYM-qYB0 Display number of non-printable, printable, and total chars output by the program. Git repo: https://github.com/pereiradaniel/beginning_c/blob/master/ch4/exercises/4_3/refactor3.c

Boulder Dash - C64 [60Hz]

Image

Lester - C64 [60 Hz]

Image

Donkey Kong - VIC-20 [60Hz]

Image

C: Character code printout with main loop repeat.

Image
Refactored version of previous program: https://youtu.be/fYuV8NQ1ieo Program loops until user quits. Git repo: https://github.com/pereiradaniel/beginning_c/blob/master/ch4/exercises/4_3/refactor2.c

C: Character code printer, user selects range of codes.

Image
Refactored version of previous program: https://youtu.be/GPl3_Hsw6Ks00 User selects range of character codes to print. Git repo: https://github.com/pereiradaniel/beginning_c/blob/master/ch4/exercises/4_3/refactor.c

Donkey Kong (Nintendo) - C64 [60Hz]

Image

C: Refactored character code table printer.

Image
Refactored version of previous program: https://youtu.be/W8me8An2fA4 Extend the previous program to output the appropriate name, such as “newline”, “space”, “tab”, and so on, for each whitespace character. Git repo: https://github.com/pereiradaniel/beginning_c/blob/master/ch4/exercises/4_3/exercise4_3.c

Donkey Kong (Ocean) - C64 [50Hz]

Image

C: Print character codes in a table.

Image
A program that will output the printable characters for character code values from 0 to 127. Each character code is printed along with its symbol. Make sure the columns are aligned. UPGRADES to original exericse!      - User selects between 1-8 columns to display.      - CHAR_MAX to control upper limit of char codes. Git repo: https://github.com/pereiradaniel/beginning_c/blob/master/ch4/exercises/4_2/exercise4_2.c

C: Print a multiplication table.

Image
Write a program that will generate a multiplication table of a size entered by the user. Git repo: https://github.com/pereiradaniel/beginning_c/blob/master/ch4/exercises/4_1/exercise4_1.c

Rainbow Islands: The Story of Bubble Bobble 2 - C64 [50Hz]

Image

C: Compact for loop.

Image
Perform calculation within the third control expression of a for loop. Git repo: https://github.com/pereiradaniel/beginning_c/blob/master/ch4/compact_for/compact.c

Bubble Bobble - C64 [50Hz]

Image

C: Summing an array of integers.

Image
Summing an array of integers without making the off by one error. Git repo: https://github.com/pereiradaniel/c_programs/blob/master/sum/sum.c

Heavenbound - C64 [50Hz]

Image

It's Magic 2 - C64 [50Hz]

Image

C: For loop off by one error demonstration.

Image
Short program demonstrating how the off by one error can happen in for loops. Git repo: https://github.com/pereiradaniel/c_programs/blob/master/counter/counter.c

Pac-Land - C64 [50Hz]

Image

Pac-Mania - C64 [50Hz]

Image

C: Looped program without using goto statement.

Image
Refactor of Exercise 3-4 without using the goto statement. Git repo: https://github.com/pereiradaniel/beginning_c/blob/master/ch3/exercises/3_4/refactor/refactor.c

C: Modify a calculator program to loop until user quits.

Image
Modify the last example in the chapter that implemented a calculator so that the user is given the option to enter y or Y to carry out another calculation, and n or N to end the program. (Note: You’ll have to use a goto statement for this here, but you’ll learn a better way of doing this in the next chapter.) Git repo: https://github.com/pereiradaniel/beginning_c/blob/master/ch3/exercises/3_4/exercise3_4.c

Super Pac-Man - C64 [50Hz]

Image

C: Calculate discount price based on quantity input by user.

Image
Write a program that will calculate the price for a quantity entered from the keyboard, given that the unit price is $5 and there is a discount of 10 percent for quantities over 30 and a 15 percent discount for quantities over 50. Git repo: https://github.com/pereiradaniel/beginning_c/blob/master/ch3/exercises/3_3/exercise3_3.c

Jr. Pac-Man - C64 [50Hz]

Image

C: Program that formats date input by the user.

Image
Short program that prompts the user to enter the date as three integer values for the month, the day in the month, and the year, and outputs the date in the form "31st December 2003" when the user enters 12 31 2003, for example. Git repo: https://github.com/pereiradaniel/beginning_c/blob/master/ch3/exercises/3_2/exercise3_2.c Blog: https://pereiradpg.blogspot.com/2023/01/c-program-that-formats-date-input-by.html Book: http://www.mosaic-industries.com/embedded-systems/_media/c-ide-software-development/learning-c-programming-language/beginning-c-5th-edition-ivor-horton.pdf

Ms. Pac-Man - C64 [50Hz]

Image

Ms. Pac-Man - C64 [60Hz]

Image

C: Using scanf to assign more than one value.

Image
Short demonstration of how scanf can be used to accept input for more than one variable assignment. In this case, an integer and a double are assigned. Note what happens when a double is entered for an integer, and vice versa.

Pac-Man - C64 [60Hz]

Image
Demonstration of Pac-Man cartridge for NTSC Commodore 64.

Pac-Man - C64 [50Hz]

Image
Demonstration of Pac-Man cartridge for PAL Commodore 64.

C: Ternary operator demonstration.

Image
Demonstrating how a ternary statement works in C. https://github.com/pereiradaniel/c_programs/blob/master/ternary/ternary.c #include <stdio.h> int main(int argc, char* argv[]) { int n = -1; // Set to -1 for do while loop. printf("\nEnter number from 0-100: \n"); // prompt user for input. // Loops until user enters valid input: do { scanf(" %d", &n); n < 0 || n > 100 ? printf("Invalid number! Try again.\n") : printf("Valid!\n"); } while(n < 0 || n > 100); // Detect whether number is less than or greater than 50: n > 50 ? printf("Number is greater than 50.\n") : printf("Number is less than 50.\n"); return 0; } https://github.com/pereiradaniel/c_programs/blob/master/ternary/ternary.txt ==119== Memcheck, a memory error detector ==119== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==119== Using Valgrind-3.15.0 and LibVEX;

C: Nested Loops.

Image
https://github.com/pereiradaniel/c_programs/blob/master/nested/nested.c // Basic demonstration of nested for loops. #include <stdio.h> int main(int argc, char* argv[]) { // Outer loop will run until i equals 3 // (three times if starting at 0) for (int i=0; i<3; ++i) { printf("\ti = %d\n", i); // Nested loop will until j equals 6 // (three times if starting at 9) for (int j=9; j>6; --j) printf("\t\tj = %d\n", j); } return 0; } https://github.com/pereiradaniel/c_programs/blob/master/nested/nested.txt ==150== Memcheck, a memory error detector ==150== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==150== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info ==150== Command: ./nested ==150== i = 0 j = 9 j = 8 j = 7 i = 1 j = 9 j = 8 j =

Zamzara - C64 [50Hz]

Image
Demonstration of Zamzara for Commodore 64.