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, November 2021
The primary focus of this laboratory work is the theoretical understanding and practical application of control structures in C, specifically:
ifif-elseswitch
These structures are essential for directing program flow based on logical conditions and user input.
| Section | Folder / File | Description |
|---|---|---|
| 1 | assign/ |
Assignment material |
| 1.1 | assign/project3.png |
Assignment description / problem statement (English) |
| 1.2 | assign/εργασία3.png |
Assignment description / problem statement (Greek) |
| 2 | docs/ |
Theoretical documentation |
| 2.1 | docs/Control-Structures.pdf |
Control structures in C (English) |
| 2.2 | docs/Δομές-Ελέγχου.pdf |
Control structures in C (Greek) |
| 3 | src/ |
Source code implementations |
| 3.1 | src/if.c |
Basic conditional statement (if) |
| 3.2 | src/if1.c |
Extended conditional logic |
| 3.3 | src/switch.c |
Multi-branch selection (switch) |
| 3.4 | src/MaxInteger.c |
Maximum value selection using conditionals |
| 3.5 | src/2ndGradeEquation.c |
Solving a second-degree equation using control logic |
| 4 | README.md |
Project documentation |
| 5 | INSTALL.md |
Usage instructions |
The documentation explores the logic and syntax of conditional execution in C.
- Detailed explanation of how expressions (arithmetic, relational, or logical) are evaluated as:
- True (non-zero)
- False (zero)
- Demonstrates how evaluation results determine the execution path of a program.
- Examples of placing
ifstatements inside otherif-elsestructures. - Used to handle more complex decision-making scenarios, such as:
- Determining whether a number is negative, positive, or zero.
- Analysis of integer-based decision-making using:
casedefault
- Emphasizes the critical role of the
breakstatement in preventing unwanted fall-through behavior.
The project includes fully documented source code for the following programs:
-
if.c&if1.c- Programs designed to find the maximum of three integers.
- Implemented using:
- Nested
if-elseblocks - The ternary operator (
?:)
- Nested
-
switch.c- Demonstrates how the
switchstatement operates on integer variables. - Shows how execution flows through cases unless explicitly stopped using
break.
- Demonstrates how the
-
2ndGradeEquation.c- A comprehensive program that solves quadratic equations of the form:
The program 2ndGradeEquation.c performs the following technical functions:
- Reads three
doublecoefficients (a,b,c) from standard input.
- Calculates the discriminant:
- Determines whether the equation is:
- Quadratic (
a ≠ 0) - Linear / Degenerate (
a = 0)
- Quadratic (
-
D > 0
- Calculates two distinct real roots.
-
D = 0
- Calculates one real (double) root.
-
D < 0
- Identifies the equation as impossible in the set of real numbers.
- Formats and prints:
- Input coefficients
- Calculated roots
- Uses high numerical precision for clarity and correctness.

