https://github.com/fatima-progmmer/function-in-c-
https://github.com/fatima-progmmer/function-in-c-
cpp function program programming-language
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/fatima-progmmer/function-in-c-
- Owner: Fatima-progmmer
- Created: 2024-03-08T04:06:59.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-04T10:53:13.000Z (12 months ago)
- Last Synced: 2025-02-04T11:31:59.781Z (12 months ago)
- Topics: cpp, function, program, programming-language
- Language: C++
- Homepage:
- Size: 1.43 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
---
# Function in C
This repository contains a C program demonstrating **functions** in C. Functions help in structuring code, improving reusability, and making programs more readable.
## 🎥 Video Explanation
I have also created a video explaining this program in detail. Watch it [here](your-video-link).
## 📝 Program Overview
- Defines a function to perform a specific task.
- Calls the function from `main()` to execute the logic.
- Demonstrates the concept of **function declaration, definition, and calling**.
## 📜 Code Snippet
```c
#include
// Function declaration
int add(int a, int b);
int main() {
int num1, num2, sum;
printf("Enter two numbers: ");
scanf("%d %d", &num1, &num2);
// Function call
sum = add(num1, num2);
printf("Sum: %d\n", sum);
return 0;
}
// Function definition
int add(int a, int b) {
return a + b;
}
```
## 🚀 How to Run
### Option 1: Compile and Run the Code
1. Clone this repository:
```sh
git clone https://github.com/Fatima-progmmer/Function-in-C-.git
```
2. Navigate to the directory:
```sh
cd Function-in-C-
```
3. Compile the program:
```sh
gcc function.c -o function
```
4. Run the executable:
```sh
./function
```
### Option 2: Run the Pre-Compiled `.exe` File (Windows)
1. Download the `function.exe` file from this repository.
2. Double-click to run it.
3. Follow the on-screen instructions.
## 📌 Explanation
- **Function Declaration** → `int add(int a, int b);`
- **Function Call** → `sum = add(num1, num2);`
- **Function Definition** → `int add(int a, int b) { return a + b; }`
## 🤝 Contributing
Feel free to fork this repository and contribute improvements!
## 📜 License
This project is open-source and free to use.
---