Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

cyril-p-jose/C-Program

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

95 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

1. ๐Ÿ“ Geometry Area Finder

A simple, interactive C program to calculate the area of common geometric shapes. This tool is perfect for beginners learning about functions and conditional logic in C.

โœจ Features

  • Circle Area: Calculates area using $\pi r^2$.
  • Square Area: Calculates area using $side^2$.
  • Rectangle Area: Calculates area using $length \times breadth$.
  • Input Validation: Basic check for menu selection.

๐Ÿš€ Getting Started

Prerequisites

You need a C compiler installed on your system (such as gcc, clang, or msvc).

Installation & Running

  1. Clone the repository:
    git clone github.com
    
    
    

#2 Celsius to Fahrenheit Converter

A simple C program that takes a temperature input in Celsius and converts it to Fahrenheit using a modular function.

๐Ÿš€ Features

  • Modular Design: Uses a separate function temp() for calculation.
  • Precision: Uses float data types to handle decimal values.
  • User-Friendly: Simple command-line interface for input and output.

๐Ÿ› ๏ธ How to Run

  1. Requirement: Ensure you have a C compiler like GCC installed.
  2. Compile:
    gcc main.c -o converter
  3. Execute:
    ./converter

#3 Student Marks Percentage Calculator

A simple and efficient C program to calculate the average percentage of a student based on marks obtained in three subjects: Science, Maths, and Sanskrit.

๐Ÿ“‹ Project Overview

This project demonstrates the use of:

  • Functions: A dedicated percentage() function to handle logic.
  • Floating Point Precision: Formatting output to 2 decimal places for accuracy.
  • User Input: interactive data collection using scanf.

๐Ÿงฎ Calculation Logic

The program assumes each subject is out of 100 marks. The formula used is:

Percentage = ((Science + Maths + Sanskrit) / 300) * 100

#4 Fibonacci Sequence Generator in C

A lightweight C program that calculates and prints the Fibonacci sequence up to a user-defined limit.
๐Ÿš€ How It Works
The program uses a simple iterative approach with three integer variables (b, c, and d) to calculate the next number in the sequence by adding the two preceding ones.

#5๐Ÿ“C Pointers

A simple exploration of memory addresses and pointer dereferencing in C.


๐Ÿ“ Description

This program demonstrates the relationship between variables, their memory addresses, and pointer variables. It showcases how to:

  • Assign an address to a pointer using the & operator.
  • Access the value at a memory address using the * operator (dereferencing).
  • Print memory addresses using the %p format specifier.

#6 ๐Ÿ“C Pointer Demonstration

A fundamental exploration of memory addresses and dereferencing in C.


๐Ÿ“‘ Overview

This repository contains a concise C program that demonstrates the relationship between a variable, its physical memory address, and a pointer. It highlights two different ways to access a value residing in memory.

๐Ÿ”ฌ Explanation

  • The Pointer (*ptr): We store the memory address of age inside ptr. By calling *ptr, we "dereference" it to see the value at that location.
  • The Address-Of Operator (&): This retrieves the specific hex code representing where the variable lives on the stack.
  • The Result: Both print statements yield 22, proving that different paths can lead to the same memory data.

๐Ÿš€ How to Run

  1. Clone the repo: git clone github.com
  2. Compile: gcc main.c -o pointer_demo
  3. Execute: ./pointer_demo

#7 ๐Ÿงฌ C Double Pointer Exploration

Demonstrating multi-level memory addressing in C.


๐Ÿ“ Overview

This program demonstrates the concept of a pointer to a pointer (double pointer). It illustrates how memory can be accessed indirectly through multiple levels of referencing, a fundamental concept for managing dynamic arrays and complex data structures.

๐Ÿ’ป Source Code


#include <stdio.h>

int main() { int i = 5; // The base value int *ptr = &i; // Single pointer: Stores address of i int **pptr = &ptr; // Double pointer: Stores address of ptr

printf("value of i from pointer to pointer: %d\n", **pptr);

return 0;

}

๐Ÿ”ฌ Key Concepts

  • int i = 5;: A standard integer variable stored at a specific memory location.
  • int *ptr = &i;: A single pointer that "points" to the address of i.
  • int **pptr = &ptr;: A double pointer (pointer to a pointer) that "points" to the address of the pointer ptr.
  • Double Dereference (**pptr): The first * retrieves the address stored in ptr, and the second * retrieves the actual integer value 5.

๐Ÿš€ Usage

  1. Clone this repository.
  2. Compile using a standard C compiler: gcc main.c -o double_pointer
  3. Run the executable: ./double_pointer

#8 ๐Ÿ”„ Integer Swap Program in C

๐Ÿ“– Project Description

This project demonstrates how to swap two integer values using a custom function. Unlike a standard "Call by Value" approach, this program uses pointers to directly manipulate memory addresses, ensuring the changes persist after the function call.

๐Ÿ”ฌ How It Works

  • Pass by Reference: We pass the addresses (&a and &b) to the swap function.
  • Dereferencing: Inside the function, we use the * operator to access and modify the actual values stored at those addresses.
  • Temporary Variable: A temp variable is used to hold one value so it isn't overwritten during the exchange.

๐Ÿš€ How to Run (2026 Edition)

  1. Ensure you have a C compiler installed (like GCC).
  2. Save the code as swap.c.
  3. Open your terminal and run:
    gcc swap.c -o swap_demo && ./swap_demo

  4. #9 ๐Ÿ”ข C Pointer Arithmetic: Sum, Product & Average


    ๐Ÿ“ Program Description

    This program calculates the Sum, Product, and Average of three user-provided integers. It emphasizes the use of pointers (int*) to pass variables to modular functions, allowing for direct memory access and cleaner logic separation.

    ๐Ÿ”ฌ Implementation Details

    • Modular Design: Calculations for sum and product are offloaded to dedicated functions for better readability.
    • Pass-by-Reference: By passing addresses (e.g., &a), the functions use *a to access the original data without creating redundant copies in memory.
    • Precision: The average is calculated using 3.0 to ensure floating-point precision, preventing integer truncation.

    ๐Ÿš€ How to Execute

    1. Clone this repository or copy the code into a file named arithmetic.c.
    2. Compile using a standard C compiler:
      gcc arithmetic.c -o arithmetic
    3. Run the program:
      ./arithmetic

    #10 ๐ŸŒ“ Call by Value vs. Call by Reference


    ๐Ÿ“˜ Concept Overview

    This program demonstrates how C handles function arguments. It provides a side-by-side comparison of two fundamental behaviors:

    • Call by Value: A copy of the variable is passed. The original variable remains untouched outside the function.
    • Call by Reference: The actual memory address is passed. Any changes made inside the function directly affect the original variable.

    ๐Ÿ”ฌ Output Analysis

    Method Terminal Output Effect on Original Variable
    Call by Value square: 25 No Change (Variable remains 5)
    Call by Reference _square: 25 Permanent Change (Variable becomes 25)

    ๐Ÿš€ Getting Started (2026)

    To run this demonstration in your local environment:

    
    # Compile the program
    gcc -o comparison main.c
    

    Run the executable

    ./comparison


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages