Skip to content

Introductory C programming examples demonstrating iterative structures (for, while, do-while), loop control (break, continue), and practical applications like Taylor series, integer operations, and pattern printing (Computer Programming, UNIWA).

Notifications You must be signed in to change notification settings

Computer-Programming-aka-Uniwa/Loops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UNIWA

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

Loops

Vasileios Evangelos Athanasiou
Student ID: 19390005

GitHub · LinkedIn


Supervision

Supervisor: Nikolaos Vassilas, Professor

UNIWA Profile

Co-supervisor: Georgios Meletiou, Laboratory Teaching Staff

UNIWA Profile


Athens, December 2021



README

Loops

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.


Table of Contents

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

1. Theoretical Background

1.1 Iterative Structures

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.

1.2 Control Commands

  • break: Immediately exits the loop and continues execution after the loop.
  • continue: Skips the current iteration and moves to the next loop cycle.

2. Source Code Implementations

2.1 MathsWithIntegersInLoopA.c

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.


2.2 Stars.c

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.


2.3 SinTaylor.c

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-while loop to sum series terms
  • Alternates addition and subtraction using a sign toggle variable

About

Introductory C programming examples demonstrating iterative structures (for, while, do-while), loop control (break, continue), and practical applications like Taylor series, integer operations, and pattern printing (Computer Programming, UNIWA).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages