Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
15 views

Programming Fundamentals Unit I-1

The document provides an overview of computer fundamentals and programming languages, covering topics such as computer organization, hardware components, software types, and the evolution of programming languages. It details the distinctions between low-level and high-level languages, as well as various programming paradigms including procedural, functional, and object-oriented programming. Additionally, it discusses syntax in programming and the importance of following specific rules for code execution.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Programming Fundamentals Unit I-1

The document provides an overview of computer fundamentals and programming languages, covering topics such as computer organization, hardware components, software types, and the evolution of programming languages. It details the distinctions between low-level and high-level languages, as well as various programming paradigms including procedural, functional, and object-oriented programming. Additionally, it discusses syntax in programming and the importance of following specific rules for code execution.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

LECTURE NOTES: UNIT I

Basics of Computer and Programming


Languages
Engr. A.W BAH
Basics of Computer and Programming
Languages

• Introduction to Computer Fundamentals


• Programming Languages
• Evolution of Programming Languages
• Problem solution and software development
• Program Development Life Cycle
• Syntax and Semantics
• Formal Methods of Describing Syntax
• Fundamentals of Grammars in Programming Language

Engr. A.W BAH, December 17, 2024. 2 of 50 pages


1. Basic Computer Organization

• Computer organization refers to the way in which the


components of a computer system are arranged and how
they interact to perform tasks.

Figure: Central Processing Unit (CPU)

Engr. A.W BAH, December 17, 2024. 3 of 50 pages


Basic Computer Organization Cont...

• Central Processing Unit (CPU): The brain of the computer,


responsible for executing instructions and processing data.
It consists of:
◦ Arithmetic Logic Unit (ALU): Performs arithmetic and logical
operations.
◦ Control Unit (CU): Directs the operation of the processor
and coordinates the activities of all components.
• Memory: Storage areas for data and instructions. Memory
can be categorized as:
◦ Primary Memory (RAM): Volatile memory used to store
data temporarily while the computer is running.
◦ Secondary Memory: Non-volatile storage used for
long-term data retention, such as hard drives and SSDs.
Engr. A.W BAH, December 17, 2024. 4 of 50 pages
Basic Computer Organization Cont...

• Input and Output Devices: Components that allow


interaction with the computer.
◦ Input Devices: Keyboard, mouse, scanner, etc., which allow
users to enter data.
◦ Output Devices: Monitor, printer, speakers, etc., which
display or produce results.

Engr. A.W BAH, December 17, 2024. 5 of 50 pages


2. Computer Hardware Components

• Understanding the key hardware components of a


computer is essential for both users and developers. The
main hardware components include:

Figure: Types of Computer Hardware

Engr. A.W BAH, December 17, 2024. 6 of 50 pages


2. Computer Hardware Components

• Keyboard: A primary input device used to enter text and


commands into the computer. It contains keys for letters,
numbers, and special functions.
• Mouse: A pointing device that allows users to interact with
the graphical user interface (GUI) of the computer. It
typically has buttons and a scroll wheel.
• Monitor: The display screen that visually presents the
output from the computer. Monitors come in various sizes
and resolutions, impacting clarity and detail

Engr. A.W BAH, December 17, 2024. 7 of 50 pages


2. Computer Hardware Components

• Printer: An output device that produces hard copies of


digital documents. There are several types of printers,
including inkjet, laser, and thermal.
• Disk Drives: Devices used to read and write data to
storage media. This includes:
◦ Hard Disk Drives (HDD): Traditional magnetic storage
devices used for long-term data storage.
◦ Solid State Drives (SSD): Faster, more reliable storage
devices using flash memory..
• CD/DVD Drives: Optical drives used to read and write data
to compact discs. They were once standard for software
installation and media playback.
Engr. A.W BAH, December 17, 2024. 8 of 50 pages
2. Computer Software

• Software refers to the set of instructions that tell the


computer how to perform specific tasks. It can be broadly
categorized into two types:

Figure: Computer Software

Engr. A.W BAH, December 17, 2024. 9 of 50 pages


Application Software

• Application Software: Application software is designed to


perform specific tasks for users. Examples include:
◦ Word Processors: Software like Microsoft Word for creating
and editing text documents.
◦ Spreadsheets: Programs like Microsoft Excel for performing
calculations and data analysis.
◦ Database Management Systems: Software for storing and
managing data, such as Microsoft Access

Engr. A.W BAH, December 17, 2024. 10 of 50 pages


System Software

• System software manages and supports computer


hardware and software resources. It includes:
◦ Operating Systems (OS): The primary system software that
manages hardware, software resources, and provides
services for application programs. Examples include
Windows, macOS, and Linux
◦ Device Drivers: Specialized software that allows the
operating system to communicate with hardware devices
◦ Compilers: Programs that convert high-level programming
languages into machine code for execution.
◦ Interpreters: Software that translates and executes code
line-by-line, allowing for real-time execution of programs.

Engr. A.W BAH, December 17, 2024. 11 of 50 pages


System Software

• System software manages and supports computer


hardware and software resources. It includes:
◦ Operating Systems (OS): The primary system software that
manages hardware, software resources, and provides
services for application programs. Examples include
Windows, macOS, and Linux
◦ Device Drivers: Specialized software that allows the
operating system to communicate with hardware devices
◦ Compilers: Programs that convert high-level programming
languages into machine code for execution.
◦ Interpreters: Software that translates and executes code
line-by-line, allowing for real-time execution of programs.

Engr. A.W BAH, December 17, 2024. 12 of 50 pages


System Software

• System software manages and supports computer


hardware and software resources. It includes:
◦ Operating Systems (OS): The primary system software that
manages hardware, software resources, and provides
services for application programs. Examples include
Windows, macOS, and Linux
◦ Device Drivers: Specialized software that allows the
operating system to communicate with hardware devices
◦ Compilers: Programs that convert high-level programming
languages into machine code for execution.
◦ Interpreters: Software that translates and executes code
line-by-line, allowing for real-time execution of programs.

Engr. A.W BAH, December 17, 2024. 13 of 50 pages


Number Systems

• A number system is a way to represent numbers in


different formats. The most commonly used systems in
computing are:

Figure: Number System

Engr. A.W BAH, December 17, 2024. 14 of 50 pages


Number System

• Binary (Base 2): Uses two symbols (0 and 1) and is the


fundamental language of computers. Each binary digit (bit)
represents a power of 2.
• Decimal (Base 10): The standard numbering system used
in daily life, using ten symbols (0-9).
• Octal (Base 8): Uses eight symbols (0-7) and is sometimes
used in computing as a shorthand for binary.

• Hexadecimal (Base 16): Uses sixteen symbols (0-9 and
A-F) and is often used in programming to represent binary
data more compactly.

Engr. A.W BAH, December 17, 2024. 15 of 50 pages


Computer Codes

• Computer codes are systems used to represent data in a


format that can be easily processed by computers. The
most widely used code is:
• ASCII (American Standard Code for Information
Interchange)
• ASCII: A character encoding standard that represents text
in computers. It assigns a unique number to each
character (e.g., letters, digits, punctuation marks). ASCII
uses 7 bits to represent 128 different characters.

Engr. A.W BAH, December 17, 2024. 16 of 50 pages


Evolution of Programming Languages

• To build programs, people use languages that are similar


to human language. The results are translated into
machine code, which computers understand.
• Therefore, programming languages are the tools we use
to write instructions for computers to follow.
• Programming languages fall into two broad categories:
◦ Low-level programming languages
▶ First Generation Languages (Machine languages)
▶ Second Generation Languages (Assembly languages)

Engr. A.W BAH, December 17, 2024. 17 of 50 pages


Evolution of Programming Languages
Cont...

• High-level programming languages


◦ Third Generation Languages
◦ Fourth Generation Languages
◦ Fifth Generation Languages

Engr. A.W BAH, December 17, 2024. 18 of 50 pages


First-Generation Languages

• Machine languages are the most basic type of computer


languages, consisting of strings of numbers the computer’s
hardware can use.
• Machine languages are the lowest level of computer
languages. Programs written in machine language consist
of 1s and 0s.
• Programs in machine language can control directly to the
computer’s hardware.

Engr. A.W BAH, December 17, 2024. 19 of 50 pages


Machine languages Cont...

• A machine language instruction consists of two parts: an


instruction part and an address part.
• The instruction part (opcode) tells the computer the
operation to be performed.
• The address part specifies the memory address of the
data to be used in the instruction.

Figure: Machie Code

Engr. A.W BAH, December 17, 2024. 20 of 50 pages


Second-Generation Languages

• Assembly languages perform the same tasks as machine


languages, but use symbolic names for opcodes and
operands instead of 1s and 0s.
• An assembly language program must be translated into a
machine language program before it can be executed on a
computer.
• Assembler: An Assembler is a program for converting
instructions written in low-level assembly code into
relocatable machine code
• To create programs in assembly language, developers use
cryptic English-like phrases to represent strings of
numbers.
Engr. A.W BAH, December 17, 2024. 21 of 50 pages
Assembly Language Code

• Example:
◦ LOAD BASEPAY
◦ ADD OVERPAY
◦ STORE GROSSPAY

Figure: Assembly Code


Engr. A.W BAH, December 17, 2024. 22 of 50 pages
Third-Generation Languages

• High-level programming languages create computer


programs using instructions that are much easier to
understand.
• Programs in a high-level languages must be translated into
a low-level language using a program called a compiler.
• A compiler translates programming code into a low-level
format.

Engr. A.W BAH, December 17, 2024. 23 of 50 pages


Third-Generation Languages

• Third-generation languages, also known as procedural


languages, are programming languages designed to be
more user-friendly by utilizing syntax similar to human
language.
• This makes it simpler for programmers to create and
understand code.
• Some well-known examples are C, C++, Java, FORTRAN,
and PASCAL.

Engr. A.W BAH, December 17, 2024. 24 of 50 pages


Fourth Generation Languages

• Fourth-generation languages are created to simplify


programming by using syntax that is more similar to
everyday human language.
• They are widely used for tasks such as database
handling, generating reports, and building graphical
user interfaces (GUIs).
• Some well-known examples are SQL, Python, Perl, Ruby,
and MATLAB.

Engr. A.W BAH, December 17, 2024. 25 of 50 pages


Fifth Generation Languages

• Fifth-generation languages represent the latest stage in


programming evolution and focus on visual programming
and artificial intelligence.
• These languages use visual tools and constraint-based
logic to create programs.
• Examples of fifth-generation languages are Prolog, OPS5,
and Mercury.

Engr. A.W BAH, December 17, 2024. 26 of 50 pages


Conclusion

• The first two generations are called low-level languages.


• The other three generations are called high-level
languages.

Figure: Generations of programming languages

Engr. A.W BAH, December 17, 2024. 27 of 50 pages


Some key terminology

• A computer program is a set of instructions used to


operate a computer to produce a specific result.
• Writing computer programs is called computer
programming.
• The languages used to create computer programs are
called programming languages.
• Software means a program or a set of programs.

Engr. A.W BAH, December 17, 2024. 28 of 50 pages


Types of Programming Languages

• Procedural programming languages


• Functional programming languages
• Object-oriented programming languages (OOP)
• Scripting languages
• Logic programming languages

Engr. A.W BAH, December 17, 2024. 29 of 50 pages


Types of Programming Languages

• Procedural programming languages


◦ A procedural language follows a sequence of statements
or commands in order to achieve a desired output.
◦ It relies on the concept of dividing a program into reusable
blocks or functions.
◦ Functions can be reused, reducing redundancy.
◦ Control structures like loops and conditionals guide
program flow.
◦ Example: C and C++, Pascal, Fortran

Engr. A.W BAH, December 17, 2024. 30 of 50 pages


Types of Programming Languages

• Functional programming languages


◦ Functional programming emphasizes pure functions and
avoids changing states or mutable data.
◦ Each function–a reusable module of code–performs a
specific task and returns a result.
◦ The result will vary depending on what data you input into
the function.
◦ Example: Scala, Erlang, Lisp, Haskell

Engr. A.W BAH, December 17, 2024. 31 of 50 pages


Types of Programming Languages

• Object-Oriented Programming (OOP) Languages


◦ This type of language treats a program as a group of
objects composed of data and program elements, known
as attributes and methods
◦ It focuses on reusability and modularity by representing
real-world entities.
◦ Objects can be reused within a program or in other
programs.
◦ This makes it a popular language type for complex
programs, as code is easier to reuse and scale.
◦ Example: Java, Python, PHP, Ruby, C++

Engr. A.W BAH, December 17, 2024. 32 of 50 pages


Types of Programming Languages

• Scripting languages
◦ Scripting languages are interpreted at runtime and are
designed to automate tasks, enhance existing systems, or
create dynamic functionality.
◦ Programmers use scripting languages to automate
repetitive tasks, manage dynamic web content, or support
processes in larger applications.
◦ Example: JavaScript, Python, PHP, Perl, Node.JS

Engr. A.W BAH, December 17, 2024. 33 of 50 pages


Types of Programming Languages

• Logic programming languages


◦ Instead of telling a computer what to do, a logic
programming language expresses a series of facts and
rules to instruct the computer on how to make decisions.
◦ Logic programming uses formal logic to express
computation.
◦ Ideal for AI, knowledge representation, and reasoning
tasks.
◦ Example: Prolog for AI and NLP, Datalog for database
queries and deductive reasoning, Absys, Alma-0

Engr. A.W BAH, December 17, 2024. 34 of 50 pages


Syntax in Programming

• Syntax refers to the set of rules and structure that define


how code must be written in a programming language.
• It ensures that a program is grammatically correct and
follows the language’s conventions.
• Rules of Syntax: These are predefined rules specifying
how to write keywords, variables, operators, and
expressions.

Engr. A.W BAH, December 17, 2024. 35 of 50 pages


Syntax in Programming

• Example: Every statement in Python or C++ or Java must


follow a specific structure, like indentation for blocks.
• If there is a syntax error, the code will not execute, and the
compiler or interpreter will throw an error.

Figure: Syntax

Engr. A.W BAH, December 17, 2024. 36 of 50 pages


Syntax in example in C and C++

Figure: C Programming Figure: C++ Programming

Engr. A.W BAH, December 17, 2024. 37 of 50 pages


Syntax in example in C and C++

Figure: C Programming Figure: C++ Programming

Engr. A.W BAH, December 17, 2024. 38 of 50 pages


Semantics in Programming

• Semantics refers to the meaning or logic behind the code.


It ensures that the written program behaves as intended
and produces the desired results.
• Even if the syntax is correct, the program might fail to
execute properly if the semantics are wrong.
• Semantics focuses on the logic and correctness of the
operations and their intended purpose.

Figure: Semantics

Engr. A.W BAH, December 17, 2024. 39 of 50 pages


Program Development Life Cycle

• The Program Development Life Cycle (PDLC) is a process


used in software engineering to manage the development
of software programs.
• It is a systematic process used to develop, maintain, and
enhance software programs.
• It consists of a series of stages to ensure that a program
meets user requirements is delivered on time, and
performs as expected.

Engr. A.W BAH, December 17, 2024. 40 of 50 pages


Program Development Life Cycle

Phases of Program Development Life Cycle


1. Planning
2. Analysis
3. Design
4. Implementation
5. Testing
6. Deployment
7. Maintenance

Engr. A.W BAH, December 17, 2024. 41 of 50 pages


Program Development Life Cycle

Steps in PDLC
1. Problem Definition
2. Feasibility Study &
Analysis
3. Program Design
4. Implementation (Coding)
5. Testing and Debugging
6. Deployment &
Maintenance
Figure: Program Development
Life Cycle
Engr. A.W BAH, December 17, 2024. 42 of 50 pages
Program Development Life Cycle

1. Problem Definition
• To understand and clearly define the problem the program
is intended to solve.
• Key Activities:
◦ Identify the program’s purpose and scope.
◦ Gather and document requirements from stakeholders.
◦ Specify constraints and success criteria.

Engr. A.W BAH, December 17, 2024. 43 of 50 pages


Program Development Life Cycle

2. Feasibility Study & Analysis


• Assess whether the project is viable in terms of technical,
financial, and operational aspects.
• Key Activities:
◦ Analyze cost, time, and resources required.
◦ Evaluate technical capabilities and tools.
◦ Identify risks and mitigation strategies.

Engr. A.W BAH, December 17, 2024. 44 of 50 pages


Program Development Life Cycle

3. Program Design
• Plan how the program will function to meet requirements.
• Key Activities:
◦ Create algorithms, flowcharts, or pseudocode.
◦ Design the program architecture (e.g., modules, data flow).
◦ Specify user interfaces and interactions.
◦ Choose appropriate programming languages and
frameworks.

Engr. A.W BAH, December 17, 2024. 45 of 50 pages


Program Development Life Cycle

4. Implementation(Coding)
• Write the program code based on the design
specifications.
• Key Activities:
◦ Develop code using the selected programming language.
◦ Adhere to coding standards and best practices.
◦ Incorporate version control for managing changes.

Engr. A.W BAH, December 17, 2024. 46 of 50 pages


Program Development Life Cycle

5. Testing and Debugging


• Ensure the program is error-free and meets requirements.
• Key Activities:
◦ Perform unit testing, integration testing, and system testing.
◦ Identify and fix bugs or errors.
◦ Test for performance, security, and usability.

Engr. A.W BAH, December 17, 2024. 47 of 50 pages


Program Development Life Cycle

6. Deployment & Maintenance


• Deliver the program to end-users and make it operational.
• Ensure the program continues to function correctly and
adapts to changing requirements.
• Key Activities:
◦ Prepare and execute deployment procedures.
◦ Provide user training and documentation.
◦ Configure the program in the live environment.
◦ Monitor program performance and address issues.
◦ Apply updates and upgrades as needed.

Engr. A.W BAH, December 17, 2024. 48 of 50 pages


Benefits of PDLC

• Facilitates communication
• Identifies and manages risks
• Improves quality
• Increases efficiency

Engr. A.W BAH, December 17, 2024. 49 of 50 pages


Limitations of PDLC

• Can be time-consuming
• Can be inflexible
• Can be costly
• Can be complex
• May not be suitable for smaller projects

Engr. A.W BAH, December 17, 2024. 50 of 50 pages

You might also like