0% found this document useful (0 votes)
59 views30 pages

Swep Project

Uploaded by

uniquedx3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views30 pages

Swep Project

Uploaded by

uniquedx3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 30

LADOKE AKINTOLA UNIVERSITY OF

TECHNOLOGY

PRESENTED BY:

FULLNAME

DANIEL PATRICK EBENEZER

MATRIC NO:2021003120

DEPARTMENT: COMPUTER SCIENCE

COURSE: SWEP

LEVEL: 200

TOPIC

5 BASIC PROGRAMMING CONCEPTS

SUPERVISOR

PROF ADETUNJI

Academic Session: [2021/2022]

1
ABSTRACT

The Student Work Experience Program (SWEP) entitled "5 Basic Programming Concepts" is

a meticulous investigation into the fundamental principles that underpin the field of

programming. This project delves into the essential building blocks of coding, aiming to

demystify and elucidate these concepts for both novice and intermediate-level programmers.

The five core programming concepts explored in this project are variables, control structures,

data structure, syntax, and programming tools. Through a combination of theoretical

research, practical application, and hands-on coding exercises, the project seeks to provide a

comprehensive understanding of how these concepts form the bedrock of computer

programming.

The methodology involves developing interactive learning modules, coding challenges, and

real-world examples to illustrate the practical applications of each programming concept.

Emphasis is placed on fostering a deep conceptual understanding, enabling learners to grasp

the significance of these foundational elements in problem-solving and software

development.

The ultimate goal of this SWEP project is to empower aspiring programmers with a solid

grasp of these fundamental concepts, thereby laying a robust foundation for their future

endeavors in the vast and dynamic realm of computer programming. By elucidating the

intricacies of these building blocks, this project aims to enhance the learning experience for

individuals embarking on their coding journey, fostering a strong conceptual framework

essential for success in the ever-evolving field of programming.

2
ACKNOWLEDGMENTS

We would like to express our sincere gratitude to:

- Prof. Adetunji for valuable guidance and support throughout this project.

- OpenAI for providing ChatGPT, which served as a valuable resource for quick learning and

problem-solving during the development of our project.

- YouTube, a platform that offers insightful tutorials and educational content, contributing

significantly to our understanding and skill development.

-Tech sites We are grateful for the wealth of information and updates from various tech sites.

These platforms have been essential in keeping me informed about the latest advancements,

trends, and best practices in the tech industry.

Collectively, these contributions have been instrumental in shaping our project and enhancing

our learning journey. We are thankful for the support, guidance, and resources that have been

crucial to our success.

3
TABLE OF CONTENT

CHAPTER ONE

INTRODUCTION……………………………………

CHAPTER TWO

5 BASIC PROGRAMMING LANGUAGE…………………………………………..

CHAPTER THREE

VARIABLE…………………………………………………

DATA STRUCTURE……………………………………...

CONTROL STRUCTURE………………………………..

SYNTAX……………………………………………………

PROGRAMMING TOOLS………………………………..

4
CHAPTER ONE

Introduction

In the vast landscape of software development, a profound understanding of the fundamental

programming concepts serves as the compass guiding developers through the intricate web of

code creation. As we embark on this exploration, we immerse ourselves in the foundational

principles that shape the art and science of programming.

At its heart, programming encapsulates a set of key principles that transcend language

barriers and form the backbone of all software endeavors. These essential concepts, woven

seamlessly into the fabric of coding, define the framework for crafting elegant and efficient

solutions.

This report aims to unravel the significance of these foundational elements, providing a

panoramic view of the essential building blocks that empower developers to transform

abstract ideas into tangible, functional realities. Through an exploration of variables, control

structures, data structures, algorithms, and syntax, we aim to shed light on the underlying

principles that give structure and meaning to lines of code.

Join us on this journey of discovery, as we navigate the terrain of programming's core

concepts, unlocking the secrets that enable developers to transcend the ordinary and create

extraordinary software solutions.

5
CHAPTER TWO

The five basic programming concepts encompass fundamental principles that form the

foundation of writing code and developing software applications. Each concept plays a

crucial role in structuring, organizing, and executing programs. Here's a list of each:

1. Variables

2. Control Structures

3. Data Structures

4. Syntax

5. Programming Tools

Understanding and mastering these five basic programming concepts is crucial for any

developer, as they form the building blocks for creating efficient, readable, and maintainable

code. These concepts provide a framework for problem-solving and are applicable across

various programming languages and paradigms

In the upcoming chapter, we will take a more detailed journey into each of these

programming concepts, exploring their nuances and understanding how they interplay to

shape the foundation of proficient coding. Join us as we unravel the intricacies of variables,

control structures, data structures, algorithms, and syntax, unlocking the essential insights

that empower developers to navigate the programming landscape with confidence and

expertise.

6
CHAPTER THREE

Variables

What is a Variable?

Variables are used to store information to be referenced and manipulated in a computer

program. They also provide a way of labeling data with a descriptive name, so our programs

can be understood more clearly by the reader and ourselves. It is helpful to think of variables

as containers that hold information. Their sole purpose is to label and store data in memory.

This data can then be used throughout your program.

Assigning Value to Variables

Naming variables is known as one of the most difficult tasks in computer programming.

When you are naming variables, think hard about the names. Try your best to make sure that

the name you assign your variable is accurately descriptive and understandable to another

reader. Sometimes that other reader is yourself when you revisit a program that you wrote

months or even years earlier.

When you assign a variable, you use the = symbol. The name of the variable goes on the left

and the value you want to store in the variable goes on the right.

irb :001 > first_name = 'Joe'

=> "Joe"

Here we've assigned the value 'Joe', which is a string, to the variable first_name. Now if we

want

7
to reference that variable, we can.

irb :002 > first_name

=> "Joe"

As you can see, we've now stored the string 'Joe' in memory for use throughout the

program.Note: Make sure you don't confuse the assignment operator (=) with the equality

operator (==).

The individual = symbol assigns value while the == symbol checks if two things are equal.

Variables are fundamental across various programming languages, although the syntax and

usage might vary. Here's a brief overview of how variables are used in some common

programming languages:Python:

These examples showcase how variables are declared, assigned, and used across different

programming languages. While the syntax may differ, the concept of variables remains

Consistent.

Data structure

What is a Data structure?A data structure is a specialized format for organizing, processing,

retrieving and storing data.

There are several basic and advanced types of data structures, all designed to arrange data to

suit a specific purpose. Data structures make it easy for users to access and work with the

data they need in appropriate ways. Most importantly, data structures frame the organization

of information so that machines and humans can better understand it.

In computer science and computer programming, a data structure may be selected or designed

to store data for the purpose of using it with various algorithms. In some cases, the

algorithm's basic operations are tightly coupled to the data structure's design. Each data

8
structure contains information about the data values, relationships between the data and -- in

some cases --

functions that can be applied to the data.

For instance, in an object-oriented programming language, the data structure and its

associated methods are bound together as part of a class definition. In non-object-oriented

languages,there may be functions defined to work with the data structure, but they are not

technically part

of the data structure.

9
python

# Declaration and assignment

age = 25

name = "John"

# Dynamic typing

x = 10 # Integer

x = "hello" # String

# Multiple assignment

a, b, c = 1, 2, 3

Java:

java

// Declaration and assignment

int age = 25;

String name = "John";

// Static typing

int x; // Declaration

x = 10; // Assignment// Constants

final int MAX_VALUE = 100;

JavaScript:

javascript

// Declaration and assignment

let age = 25;

const PI = 3.14;

10
// Dynamic typing

let x = 10; // Integer

x = "hello"; // String

// var keyword (pre-ES6)

var y = 5;

C++:

cpp

// Declaration and assignment

int age = 25;

double price = 12.99;// Static typing

int x;

// Declaration

x = 10; // Assignment

// Constants

const int MAX_VALUE = 100;

Why are data structures important?

Typical base data types, such as integers or floating-point values, that are available in most

computer programming languages are generally insufficient to capture the logical intent for

data processing and use. Yet applications that ingest, manipulate and produce information

must understand how data should be organized to simplify processing. Data structures bring

together the data elements in a logical way and facilitate the effective use, persistence and

sharing of data. They provide a formal model that describes the way the data elements are

Organized.

11
Data structures are the building blocks for more sophisticated applications. They are designed

by composing data elements into a logical unit representing an abstract data type that has

relevance to the algorithm or application. An example of an abstract data type is a "customer

name" that is composed of the character strings for "first name," "middle name" and "last

name."

It is not only important to use data structures, but it is also important to choose the proper

data structure for each task. Choosing an ill-suited data structure could result in slow

runtimes or unresponsive code.

Five factors to consider when picking a data structure include the following:

-What kind of information will be stored?

-How will that information be used?

-Where should data persist, or be kept, after it is created?

-What is the best way to organize the data?

-What aspects of memory and storage reservation management should be considered?

Data structures are essential for organizing and managing data efficiently in programming.

Different programming languages provide various built-in or library-supported data

structures.

Here's a brief overview of how data structures are commonly used in several programming

Languages:

1. Python:

- Lists: Dynamic arrays, versatile and widely used.

12
python

my_list = [1, 2, 3, 4, 5]

- Dictionaries: Key-value pairs for fast data retrieval.

```python

my_dict = {"name": "John", "age": 25}

- Sets: Unordered collections with unique elements.

```python

my_set = {1, 2, 3, 4, 5}```

- Tuples: Immutable sequences.

```python

my_tuple = (1, 2, 3)

```

2. Java:

- ArrayList: Dynamic arrays with flexible size.

```java

ArrayList<Integer> myList = new ArrayList<>();

```

- HashMap: Key-value pairs for efficient data retrieval.

```java

HashMap<String, Integer> myMap = new HashMap<>();

```

- HashSet: Unordered collection with unique elements.

```java

13
HashSet<Integer> mySet = new HashSet<>();

```

- LinkedList: Doubly-linked list for easy insertion and removal.

```javaLinkedList<String> myLinkedList = new LinkedList<>();

```

3. JavaScript:

- Arrays: Dynamic arrays with flexible size.

```javascript

let myArray = [1, 2, 3, 4, 5];

```

- Objects: Key-value pairs for versatile data representation.

```javascript

let myObject = { name: "John", age: 25 };

```

- Sets: Unordered collections with unique elements.

```javascript

let mySet = new Set([1, 2, 3, 4, 5]);

```

- Maps: Key-value pairs with flexible key types.

```javascript

let myMap = new Map();

```

4. C++:- Vectors: Dynamic arrays with flexible size.

```cpp

14
std::vector<int> myVector = {1, 2, 3, 4, 5};

```

- Maps: Key-value pairs for efficient data retrieval.

```cpp

std::map<std::string, int> myMap;

```

- Sets: Unordered collections with unique elements.

```cpp

std::set<int> mySet = {1, 2, 3, 4, 5};

```

- Queues and Stacks: Useful for specific operations.

```cpp

std::queue<int> myQueue;

std::stack<int> myStack;

```

These examples illustrate the usage of data structures in different programming languages.

The choice of a data structure depends on the specific requirements and operations needed for

a particular program.

Control structure

What is a Control structure?

Control Structures are just a way to specify flow of control in programs. Any algorithm or

program can be more clear and understood if they use self-contained modules called as logic

or control structures. It basically analyzes and chooses in which direction a program flows

15
based on certain parameters or conditions. There are three basic types of logic, or flow of

control,

known as:

Sequence logic, or sequential flow

Selection logic, or conditional flow

Iteration logic, or repetitive flow

Let us see them in detail:

Sequential Logic (Sequential Flow) Sequential logic as the name suggests follows a serial or

sequential flow in which the flow depends on the series of instructions given to the computer.

Unless new instructions are given, the modules are executed in the obvious sequence. The

sequences may be given, by means of numbered steps explicitly. Also, implicitly follows the

order in which modules are written. Most of the processing, even some complex problems,

will generally follow this elementary flow pattern.

Sequential Control flowSelection Logic (Conditional Flow) Selection Logic simply involves

a number of conditions or

parameters which decides one out of several written modules. The structures which use these

type of logic are known as Conditional Structures. These structures can be of three types:

Single AlternativeThis structure has the form:

If (condition) then:

16
[Module A]

[End of If structure]

Implementation:

C/C++ if statement with Examples

Java if statement with Examples

Double AlternativeThis structure has the form:

If (Condition), then:

[Module A]

Else:

[Module B]

[End if structure]

Implementation:

C/C++ if-else statement with Examples

Java if-else statement with Examples

Multiple AlternativesThis structure has the form:

If (condition A), then:

[Module A]

Else if (condition B), then:

[Module B]

....

Else if (condition N), then:

[Module N]

[End If structure]

Implementation:

C/C++ if-else if statement with Examples

17
Java if-else if statement with Examples

In this way, the flow of the program depends on the set of conditions that are written. This

can

be more understood by the following flow charts:

Double Alternative Control Flow Iteration Logic (Repetitive Flow) The Iteration logic

employs a loop which involves a repeat

statement followed by a module known as the body of a loop. The two types of these

structures are:Repeat-For Structure This structure has the form:

Repeat for i = A to N by I:

[Module]

[End of loop]

Here, A is the initial value, N is the end value and I is the increment. The loop ends when

A>B. K

increases or decreases according to the positive and negative value of I respectively.

18
Repeat-For Flow

Implementation:

C/C++ for loop with Examples

Java for loop with Examples

Repeat-While Structure It also uses a condition to control the loop. This structure has the

form:

Repeat while condition:

[Module]

[End of Loop]

Repeat While FlowImplementation:

C/C++ while loop with Examples

Java while loop with Examples

In this, there requires a statement that initializes the condition controlling the loop, and there

must also be a statement inside the module that will change this condition leading to the end

of the loop.

19
Control structures are fundamental for managing the flow of a program. Different

programming languages use various constructs for control flow. Here's an overview of

control structures in several programming languages:

1. Python

- if-else:

```python

if condition:

# code block

else:

# code block

```

- for loop:

```python

for variable in iterable:

# code block

```

- while loop:

20
```python

while condition:

# code block

```

2. Java:

- if-else:

```java

if (condition) {

// code block

} else {

// code block

```

- for loop:

```java

for (int i = 0; i < limit; i++) {

// code block

```

-*while loop:

```java

while (condition) {// code block

```

21
3. JavaScript:

- if-else:

```javascript

if (condition) {

// code block

} else {

// code block

```

- for loop:

```javascript

for (let i = 0; i < limit; i++) {

// code block

```

- while loop:

```javascript

while (condition) {

// code block}

```

4. C++:

- if-else:

```cpp

if (condition) {

22
// code block

} else {

// code block

```

- for loop:

```cpp

for (int i = 0; i < limit; i++) {

// code block

```

- while loop:

```cpp

while (condition) {

// code block

}```

These examples illustrate the syntax of control structures in various programming languages.

The specific syntax and features may vary, but the core concepts remain consistent across

Languages.

Syntax

What is a Syntax?

23
Syntax refers to the rules that define the structure of a language. Syntax in computer

programming means the rules that control the structure of the symbols, punctuation, and

words of a programming language.

Without syntax, the meaning or semantics of a language is nearly impossible to understand.

For example, a series of English words, such as — subject a need and does sentence a verb —

has little meaning without syntax.

Applying basic syntax results in the sentence — Does a sentence need a subject and verb?

Programming languages function on the same principles.

If the syntax of a language is not followed, the code will not be understood by a compiler or

Interpreter.

Compilers convert programming languages like Java or C++ into binary code that computers

can understand. If the syntax is incorrect, the code will not compile.

Interpreters execute programming languages such as JavaScript or Python at runtime. The

incorrect syntax will cause the code to fail.That’s why it is crucial that a programmer pays

close attention to a language’s syntax. No

programmer likes to get a syntax error.

What Is Basic Syntax?

Basic syntax represents the fundamental rules of a programming language. Without these

rules, it is impossible to write functioning code.

Every language has its own set of rules that make up its basic syntax. Naming conventions

are a primary component of basic syntax conventions and vary by language.

Case Sensitive. Java, C++, and Python are examples of languages that are case-sensitive.

24
Identifiers such as world and World have different meanings in these languages. Languages

such as Basic and SQL are insensitive, meaning world and World have the same meaning.

Class Names. Java requires the first letter of each word in class names be upper case. For

example, class FirstJavaClass. Languages such as C or C++ use an underscore to separate

words. In C, the class name would be first_java_class.

Program Filenames. The name of a Java program file must match the class name with the

extension ‘*.java” added to the name. For example, FirstJavaClass.java would be the name of

the program file for the class FirstJavaClass. C and C++ files require a “*.c” or “*.cpp”

extension but have no other stipulations.

Different languages may have rules for adding comments, using white space, or declaring

Variables. Object-oriented languages such as Java and C use methods that have different

syntax

requirements.

The first step in learning any programming language is to understand the basics such as

phrase structure, proper syntax and correctly structured code.

Understanding Syntaxunderstanding syntax programming woz-u.com

Human languages have syntax. These rules stipulate word order, punctuation and sentence

Structure. Without these rules, it would be impossible to communicate in a given language.

When learning a foreign language, one of the first steps is learning its syntax.

Writing code requires the same focus on syntax. Once the code is written, it is read multiple

times by different people.

Sometimes the code may be read years after it is written, making coding standards necessary.

Coding standards can make the code easy to understand.

Why Is Syntax Important in Programming?

25
Syntax improves code readability. It ensures that the four C’s of coding are maintained:

Communication

Code integration

Consistency

Clarity

The concept behind conventions is to make the code explain itself. If the code is self-

explanatory, the focus can be on design and program improvements and not on what does this

mean?

Using consistent standards means that code is predictable and discoverable when read by

other programmers.When code does not follow conventions, it becomes disorganized and

difficult to read. It

becomes what is known as spaghetti code.

The term has a negative connotation indicating that the programmer did not have the skills or

experience needed to write readable code.

Syntax refers to the rules and conventions that govern how code is written in a programming

language. Here's an overview of the syntax in several programming languages:

26
1. Python:

- Uses indentation for blocks of code (no braces).

- Statements end with a newline character.

```python

if condition:

# indented code block

```

2. Java:

- Uses curly braces `{}` to delineate blocks of code.

- Statements end with a semicolon `;`.

```java

if (condition) {

// code block

```

3. JavaScript:- Uses curly braces `{}` like Java.

- Statements usually end with a semicolon `;`, though it's optional in some cases.

```javascript

if (condition) {

// code block

```

4. C++:

- Similar to Java, uses curly braces `{}` for blocks of code.

27
- Statements end with a semicolon `;`.

```cpp

if (condition) {

// code block

```

These examples demonstrate the syntax differences among various programming languages.

Each language has its own rules and conventions, but they share common concepts such as

blocks of code, conditionals, and loops.

28
Programming Tools

What is a Programming Tool?

A programming tool is a software application or a set of programs designed to assist

programmers in the development, testing, and maintenance of computer programs. These

tools aim to make the software development process more efficient, error-free, and

manageable.

Programming tools serve various purposes, and they can fall into different categories based

on their functionalities. Some common types of programming tools include:

Various tools are commonly used in programming to aid developers in writing, testing, and

maintaining code. Here's an overview of some commonly used tools across programming

languages:

1. Text Editors:

- VSCode: A highly popular, open-source code editor with a rich set of extensions and

features.

- Sublime Text: A lightweight and customizable text editor.

- Atom: A hackable text editor developed by GitHub.

2. Integrated Development Environments (IDEs):-

Eclipse,IntelliJ IDEA, Visual Studio:

3. Version Control:

- Git, GitHub, GitLab, Bitbucket

4. Package Managers:

- npm: Node.js package manager for JavaScript/Node.js.

- pip: Python package installer.

- Maven and Gradle: Dependency management tools for Java.

5. Compilers and Interpreters:

29
- GCC (GNU Compiler Collection): A compiler system supporting various languages,

including C and C++.

- Java Compiler (javac): Compiles Java source code.

- Python Interpreter (CPython): Interprets and executes Python code.

6. Build Tools:

- Make: A build automation tool.

- Apache Ant and Apache Maven:** Build tools for Java projects.

- CMake: Cross-platform build system.7. **Testing Frameworks:**

8. Debuggers:

- GDB (GNU Debugger): A powerful debugger for C, C++, and other languages.

- pdb: Python debugger.

- Visual Studio Debugger: Integrated debugger for Visual Studio.

10. Continuous Integration/Continuous Deployment (CI/CD):

- Jenkins, Travis CI, CircleCI: CI/CD tools automating the testing and deployment pipeline.

- GitHub Actions: Integrated CI/CD within GitHub repositories.

12. Documentation Tools:

- Doxygen, Javadoc, Sphinx: Tools for generating documentation from source code

comments.

13. Editors for Specialized Languages:

These tools cater to different aspects of the development process, enhancing productivity and

code quality across various programming languages. The choice of tools often depends on the

specific requirements and preferences of the development team.

30

You might also like