A collection of my C programming algorithms, logic building exercises, and academic codes for my B.Tech CSE (AI & DS).
This repository tracks my progress while learning the fundamentals of C programming. The examples focus on variables, input and output, arithmetic, conditionals, and basic problem-solving.
All examples are stored in the Simple Algorithms directory. Each program is a standalone C file with its own main function.
| File | What it does | Main concepts |
|---|---|---|
absolute.c |
Finds the absolute value of an integer. | if-else, unary negation |
age_vote.c |
Calculates age from a birth year and checks voting eligibility. | Input, arithmetic, conditionals |
average.c |
Calculates the average of three integers. | Arithmetic operators, integer division |
conditional_swap.c |
Updates three values conditionally and prints their sum. | Nested conditionals, arithmetic |
division.c |
Divides two user-provided numbers. | float, input, arithmetic |
interest.c |
Calculates simple interest. | Formula translation, float |
leap_year.c |
Checks whether a year is a leap year. | Logical operators, modulo operator |
numcheck.c |
Identifies whether a number is positive, negative, or zero. | if-else if-else, comparisons |
scan_sub.c |
Subtracts one user-provided integer from another. | scanf, variables, arithmetic |
sum.c |
Adds two predefined integers. | Variables, assignment, printf |
swap.c |
Swaps two integers using a temporary variable. | Assignment, temporary storage |
tax.c |
Calculates tax and the final price of a product. | Percentages, float, arithmetic |
time_convertor.c |
Converts days into hours, minutes, and seconds. | Unit conversion, arithmetic |
You need a C compiler such as GCC. On Windows, MinGW-w64 is a common choice.
Clone the repository and open the examples directory:
git clone https://github.com/im-nitin/C.git
cd "C/Simple Algorithms"Compile a program and run it. Replace sum with any filename from the table:
gcc sum.c -o sumOn Windows PowerShell:
.\sum.exeOn Linux or macOS:
./sumMost programs read values from standard input. Follow the prompts after starting the executable.
- C syntax, variables, and data types
- Console input and output with
scanfandprintf - Arithmetic and percentage calculations
- Conditional logic and comparison operators
- Translating everyday problems into small algorithms