⭐️ 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:
caesar.c
- A program that encrypts messages using the Caesar cipher.readability.c
- A program that determines the readability grade level of a given text using the Coleman-Liau index.scrabble.c
- A program that simulates a simple game of Scrabble between two players.substitution.c
- A program that encrypts messages using a substitution cipher.
The caesar.c
program encrypts messages using the Caesar cipher.
- The user provides a non-negative integer key via command-line arguments.
- The program prompts the user for plaintext.
- Each letter in the plaintext is shifted according to the key.
- The resulting ciphertext is printed.
- Validates that the key is a non-negative integer.
- Shifts both uppercase and lowercase letters.
- Leaves non-alphabetic characters unchanged.
- Utilizes functions like
isdigit
,isalpha
, andisupper
fromctype.h
.
The readability.c
program determines the readability grade level of a given text using the Coleman-Liau index.
- The program prompts the user to enter the text.
- It counts the number of letters, words, and sentences in the text.
- It calculates the average number of letters per 100 words and the average number of sentences per 100 words.
- It computes the Coleman-Liau index and prints the grade level.
- Uses the Coleman-Liau index formula:
index = 0.0588 * L - 0.296 * S - 15.8
. - Outputs "Before Grade 1" for very simple texts and "Grade 16+" for very complex texts.
The scrabble.c
program simulates a simple game of Scrabble between two players.
- Each player inputs a word.
- The program calculates the score for each word based on Scrabble letter values.
- It determines the winner based on the scores and prints the result.
- Defines a points array for each letter of the alphabet.
- Converts letters to lowercase to handle case insensitivity.
- Uses
isalpha
to ensure only alphabetic characters contribute to the score.
The substitution.c
program encrypts messages using a substitution cipher.
- The user provides a 26-character key via command-line arguments.
- The program validates the key to ensure it contains 26 unique alphabetic characters.
- The program prompts the user for plaintext.
- Each letter in the plaintext is mapped to a different letter in the ciphertext based on the key.
- The resulting ciphertext is printed.
- Handles both uppercase and lowercase letters.
- Leaves non-alphabetic characters unchanged.
- Utilizes functions like
isalpha
,tolower
,toupper
, andstrcat
fromctype.h
andstring.h
.
![]() |
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. |