UNIVERSITY OF WEST ATTICA
SCHOOL OF ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING AND INFORMATICS
University of West Attica · Department of Computer Engineering and Informatics
Computer Programming
Vasileios Evangelos Athanasiou
Student ID: 19390005
Supervision
Supervisor: Nikolaos Vassilas, Professor
Co-supervisor: Georgios Meletiou, Laboratory Teaching Staff
Athens, December 2021
This project explores the fundamental concepts of iterative structures (loops) in the C programming language. It provides a comprehensive theoretical background followed by practical implementations through various source code examples.
| Section | Folder / File | Description |
|---|---|---|
| 1 | assign/ |
Assignment material |
| 1.1 | assign/project4.png |
Assignment description / problem statement (English) |
| 1.2 | assign/εργασία4.png |
Assignment description / problem statement (Greek) |
| 2 | docs/ |
Theoretical documentation |
| 2.1 | docs/Loops.pdf |
Loops and iteration in C (English) |
| 2.2 | docs/Βρόχοι.pdf |
Loops and iteration in C (Greek) |
| 3 | src/ |
Source code implementations |
| 3.1 | src/MathsWithIntegersInLoopA.c |
Integer operations using for/while loops (example A) |
| 3.2 | src/MathsWithIntegersInLoopB.c |
Integer operations using for/while loops (example B) |
| 3.3 | src/SinTaylor.c |
Computing sine using Taylor series in loops |
| 3.4 | src/Stars.c |
Loop exercises: printing patterns (stars) |
| 4 | README.md |
Project documentation |
| 5 | INSTALL.md |
Usage instructions |
Iterative structures are instructions that execute a body of code repeatedly based on a specific condition.
- The loop continues while the condition is true (non-zero)
- Terminates when the condition becomes false (zero)
Supported Loops in C:
while: Executes a body of instructions as long as the condition evaluates to true.do-while: Executes the loop body at least once, then checks the condition.for: Commonly used for a predetermined number of iterations, accepts initialization, condition, and modification.
break: Immediately exits the loop and continues execution after the loop.continue: Skips the current iteration and moves to the next loop cycle.
Performs mathematical operations on a user-defined number of integers.
Functionality:
- Calculates the square of odd numbers
- Counts the number of even numbers
- Computes the average of positive numbers
- Computes the product of negative numbers
Key Logic:
Uses a while loop that iterates until the counter i reaches the user-specified limit N.
Visualizes geometric shapes using asterisks (*) based on user input for the number of lines.
Functionality:
- Plots four distinct asterisk-based figures
- Figure 1: Right-angled triangle
- Figure 4: Square perimeter with diagonal markings
Key Logic:
Uses nested for loops to handle row and column positions for characters.
Calculates the sine of an angle using the Taylor series and compares it with the standard library sin() function.
Functionality:
- Converts user-inputted degrees to radians
- Iteratively computes Taylor series terms until the difference between successive terms < 10⁻⁶
Key Logic:
- Uses a
do-whileloop to sum series terms - Alternates addition and subtraction using a sign toggle variable
