https://github.com/fatima-progmmer/for-loop
https://github.com/fatima-progmmer/for-loop
coding cplus cpp forloop programming
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/fatima-progmmer/for-loop
- Owner: Fatima-progmmer
- Created: 2024-09-09T05:01:53.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-08T02:37:41.000Z (10 months ago)
- Last Synced: 2025-03-08T03:23:47.247Z (10 months ago)
- Topics: coding, cplus, cpp, forloop, programming
- 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
# For Loop in C
## Overview
This repository contains an implementation and explanation of the **for loop** in the C programming language. The `for` loop is one of the most commonly used loops in C, allowing controlled iteration with initialization, condition checking, and increment/decrement in a single line.
## Key Features
- Demonstrates the syntax and working of the `for` loop.
- Provides example programs for better understanding.
- Helps beginners grasp the concept through practical implementation.
## Syntax
```c
#include
int main() {
int i;
for (i = 1; i <= 5; i++) {
printf("%d\n", i);
}
return 0;
}
```
## Explanation
1. **Initialization**: The loop starts by initializing `i = 1`.
2. **Condition Checking**: It checks if `i <= 5`. If true, the loop body executes; otherwise, the loop terminates.
3. **Iteration Update**: The loop variable `i` is incremented after each iteration.
## Example Output
```
1
2
3
4
5
```
## How to Run the Code
1. Clone the repository:
```sh
git clone https://github.com/Fatima-progmmer/For-loop
```
2. Navigate to the project folder:
```sh
cd For-loop
```
3. Compile the program using GCC:
```sh
gcc for_loop_example.c -o for_loop_example
```
4. Run the executable:
```sh
./for_loop_example
```
## Contribution
Feel free to contribute by adding more examples, improving documentation, or optimizing the code. Fork the repository and create a pull request with your changes.
## License
This project is open-source and available under the **MIT License**.
---
### Author: Tanzeela Fatima
For more projects and contributions, visit my [GitHub Profile](https://github.com/Fatima-progmmer).