⭐️ Star this repository! It really motivates me to make better explanations and produce more work!! ⭐️
This repository contains several C programs that perform different tasks:
cash.c
- A program that calculates the minimum number of coins required to give a user change.credit.c
- A program that checks the validity of a credit card number using Luhn's Algorithm and identifies the type of card (AMEX, MASTERCARD, VISA).hello.c
- A simple program that prompts the user for their name and prints a greeting.mario_less.c
- A program that prints a half-pyramid of a specified height using hashes.mario_more.c
- A program that prints a full pyramid with a gap in the middle of a specified height using hashes.
The cash.c
program calculates the minimum number of coins needed to make change for a given amount of money in cents. It uses U.S. coin denominations (quarters, dimes, nickels, and pennies).
- The program prompts the user to enter a non-negative amount of change owed.
- The input is validated to ensure it is non-negative.
- The program calculates the number of quarters, dimes, nickels, and pennies required to make the change.
- The total number of coins is printed.
- Uses U.S. coin denominations: quarters (25¢), dimes (10¢), nickels (5¢), and pennies (1¢).
- Implements a greedy algorithm to minimize the number of coins.
The credit.c
program validates a credit card number using Luhn's Algorithm and identifies the card type (AMEX, MASTERCARD, VISA).
- The program prompts the user to enter a credit card number.
- It checks the validity of the card number using Luhn's Algorithm.
- If the card number is valid, it identifies the type of card based on the number's prefix and length.
- The program prints the card type or "INVALID" if the card number is not valid.
- Uses Luhn's Algorithm for credit card validation.
- Identifies card type based on prefix and length:
- AMEX: 15 digits, starts with 34 or 37.
- MASTERCARD: 16 digits, starts with 51-55.
- VISA: 13 or 16 digits, starts with 4.
The hello.c
program prompts the user for their name and then prints a greeting.
- The program prompts the user to enter their name.
- It prints "Hello, [name]" using the entered name.
- Demonstrates basic input and output operations in C.
- Simple example of user interaction.
The mario_less.c
program prints a half-pyramid of a specified height using hashes.
- The program prompts the user to enter a height between 1 and 8.
- It prints a right-aligned half-pyramid of the specified height.
- Utilizes loops to print a right-aligned half-pyramid.
- Emphasizes understanding of nested loops and character output.
The mario_more.c
program prints a full pyramid with a gap in the middle of a specified height using hashes.
- The program prompts the user to enter a height between 1 and 8.
- It prints a full pyramid of the specified height with two spaces in the middle.
- Builds on the concepts from
mario_less.c
to create a more complex pattern. - Demonstrates control over spacing and alignment in text output.
This project was inspired by and developed as part of the CS50x course offered by Harvard University. CS50x is Harvard University's introduction to the intellectual enterprises of computer science and the art of programming for majors and non-majors alike, with or without prior programming experience.
Thank you to the CS50x team for providing such a comprehensive and engaging introduction to computer science. |