UNIVERSITY OF WEST ATTICA
SCHOOL OF ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING AND INFORMATICS
Computer Programming
Vasileios Evangelos Athanasiou
Student ID: 19390005
Supervisor: Georgios Meletiou, Laboratory Teaching Staff
Athens, October 2021
This report covers the fundamental concepts of the C programming language, including:
- The definition of a computer program
- The software development lifecycle
- Categories of programming errors
In addition, it presents a practical analysis of a C program designed to perform basic arithmetic operations on integers, highlighting common mistakes and their corrections.
| Section | Folder / File | Description |
|---|---|---|
| 1 | assign/ |
Assignment material |
| 1.1 | assign/project1.png |
Assignment description / problem statement (English) |
| 1.2 | assign/εργασία1.png |
Assignment description / problem statement (Greek) |
| 2 | docs/ |
Theoretical documentation |
| 2.1 | docs/Introduction.pdf |
Introductory theory and concepts (English) |
| 2.2 | docs/Εισαγωγή.pdf |
Introductory theory and concepts (Greek) |
| 3 | src/ |
Source code implementations |
| 3.1 | src/C1aCorrect.c |
Correct implementation of the exercise |
| 3.2 | src/C1aWrong.c |
Incorrect implementation (for comparison / analysis) |
| 4 | README.md |
Repository overview and instructions |
A program is defined as a sequence of commands provided by a user to solve a specific problem. These commands instruct the computer on how to process data and produce the desired output.
The report outlines the following seven key stages involved in developing and executing a C program:
-
Editing
Writing the source code using a C programming environment. -
Saving
Storing the source code in a file with the.cextension. -
Compilation
Using a compiler to detect and report syntax errors in the source code. -
Machine Language Conversion
Translating the corrected source code into an object file (.obj) that the processor can understand. -
Linking
Connecting the object file with required libraries (e.g.,stdio.h) to produce an executable file (.exe). -
Executable Generation
Finalizing the executable file so it can be run by the operating system. -
Running
Executing the program to perform its intended operations and produce output.
| Error Type | Description | Example |
|---|---|---|
| Syntax Error | Violations of the language’s grammatical rules | Missing semicolon or quotation mark |
| Logical Error | Errors in logic that the compiler cannot detect | Using subtraction instead of addition |
| Runtime Error | Errors that occur during execution and stop the program | Division by zero |
The paper analyzes two versions of a C program:
C1aWrong.c– Contains multiple errorsC1aCorrect.c– Corrected version of the program
-
Missing Quotes
Failure to close a string literal in aprintf()statement. -
Case Sensitivity
Attempting to use a lowercase variable (c) when it was declared as uppercase (C). -
Character Encoding Issues
Using a Greek character "Ε" instead of the Latin "E" in a variable name. -
Typographical Errors
Misspellingprintfasprantf, which is detected during the linking stage.
The program was tested using various integer inputs to demonstrate how C handles arithmetic operations.
When performing the operation:
5/10The program returns:
0This occurs because both operands are declared as int. As a result, the decimal portion of the division is truncated, not rounded.
Using very large values (e.g., 54,645,234,234) produces incorrect negative results.
This behavior is caused by integer overflow, where the value exceeds the maximum range supported by the standard int data type.
This repository contains introductory material and example source code for C programming, developed for the Computer Programming course at the University of West Attica (UNIWA).
The project includes theoretical documentation and simple C source files intended for compilation and execution on a local machine.
-
C Compiler
- Recommended:
- GCC (Linux / macOS / Windows via MinGW or WSL)
- Recommended:
-
Text Editor or IDE
- Visual Studio Code
(Recommended) - Code::Blocks
- Dev-C++
- CLion
- Any plain text editor
- Visual Studio Code
- Windows
- Linux
(Recommended) - macOS
Clone the repository to your local machine:
git clone https://github.com/Computer-Programming-aka-Uniwa/Intro.git- Open the repository URL in your browser
- Click Code → Download ZIP
- Extract the ZIP file to a local directory
cd Intro/srcUsing GCC:
gcc C1aCorrect.c -o C1aCorrectLinux / macOS:
./C1aCorrectWindows:
C1aCorrect.exe- Navigate to the
docs/directory - Open the report corresponding to your preferred language:
- English:
Introduction.pdf - Greek:
Εισαγωγή.pdf
- English:
