Problem Solving and Programming

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 42

“Inspiring Minds”

Problem Solving and


Programming Fundamentals
CCC 1123

Siti Zainab Ibrahim


zainab.ibrahim@aiu.edu.my
Warm-Up Session

● What do you think programmers do?


● Do you want to be a programmer? Why?
Introduction to Computer &
Programming Language
Overview

Computer & Hardware Generations of


Programming
Software and Languages
Operating Systems
Number Systems
Language Processors
Computer & Hardware
What is Computer?

o A programmable electronic device designed to provide


various services.
o Stores, retrieves, and processes data efficiently.
o Received data and instructions through “Input Devices”
that get processed in the Central Processing Unit (CPU)
and the result is displayed to “Output Devices”.
o A combination of Hardware and Software.
Hardware
Physical components of a computer:
❑ Input devices
❑ Output devices
❑ Processor/CPU (Central Processing
Unit)
❑ Memory/RAM (Random Access
Memory, non-persistent storage)
❑ Storage or auxiliary/secondary
memory (persistent storage)
Computer Hardware

o Input devices: devices are used to input data and instructions into the
computer. E.g. keyboard, mouse.
o CPU (Central Processing Unit): Responsible for processing data and
instructions. It receives data from input devices. It processes the data
and stores the output or display to the output devices. It is divided
into three sections:
➢ ALU (Arithmetic & Logical Unit): Responsible for performing various arithmetic
operations like addition, subtraction, etc.
➢ CU (Control Unit): Responsible for coordinating and controlling data in and out of
the CPU.
➢ Memory Registers: Non-persistent/temporary storage in the CPU – storing data
that is directly used by the CPU.
Computer Hardware (Cont.)

o Output devices: devices are used to display the result to the user. E.g.
monitor, printer.
o Memory/RAM: Memory attached to the CPU – is used to store data
and instructions. Data is loaded when a program is executed and
remains in the memory till the program end.
o Storage or auxiliary memory: Persistent storage of data in which the
data resides even if we switch off the computer. E.g. hard-drives, CD,
DVD.
Generations of
Computers
First Generation

● The period of first generation: 1946 – 1959


● Core technology: Vacuum tube-based
● Use Machine code ad the programming language

Advantage:
● Could perform various operations in milliseconds.
Disadvantages:
● Very big in size, weight in tons.
● Very costly.
● Not efficient.
● Huge electricity consumption.
● Punch cards and magnetic tapes are used to take input.
Second Generation

● The period of second generation: 1959 - 1965


● Core technology: Transistor-based
● Assembly language and high-level programming languages like FORTRAN, COBOL were
used.

Advantage:
● Quite small and low cost compared with the first generation.
Disadvantages:
● Still produces a lot of heat, so a cooling system is required.
● Very limited usage.
● Still, punch cards are used to take input.
Third Generation

● The period of third generation: 1965 - 1971


● Core technology: Integrated Circuit (IC)
● High-level languages like FORTRAN-II TO IV, COBOL, PASCAL, BASIC etc. were used.

Advantage:
● Smaller and cheaper than the second generation.
● The mouse and keyboard are used to take input.
● Fast and reliable.
● Storage capacity is increased.
● Computational time is reduced from microseconds to nanoseconds.
Disadvantages:
● Still, a cooling system is required.
● IC chips are difficult to make.
Fourth Generation

● The period of fourth generation: 1971 - 1980


● Core technology: Very Large Scale Integrated (VLSI) microprocessor
● High-level languages like C, C++ etc. were used.

Advantage:
● Smaller in size compared to the third generation.
● All types of high-level languages are used.
● Faster than the previous generation.
● Less heat generated.

Disadvantages:
● VLSI chips design and fabrication is complex.
Fifth Generation

● The period of the fifth generation: 1980 onwards.


● Core technology: Ultra Large Scale Integration (ULSI) microprocessor and Artificial
Intelligence (AI)
● All the high-level languages like C and C++, Java, .Net, etc. are used.

Advantage:
● Very light and handy.
● Reliable and work faster.
● All high-level languages can be used.
Disadvantages:
● ULSI chip design and fabrication is very complex.
Generation of
Programming Language
Programming Language

• A programming language is a formal language comprising a


set of instructions that produce various kinds of output.
• Programming languages are used in computer programming
to implement algorithms (i.e. working procedures).
1GL

• Machine-level language
• Used to program first-generation computers.
2GL

• Assembly languages i.e. mnemonic


3GL

• Much more machine-independent


• More programming-friendly
4GL
• These are languages that consist of statements that are similar to
statements in the human language.
• Used to solve very specific problems.
• May include support for database management, report generation,
mathematical optimization, GUI development, or web development.
5GL

• Solve the problem based on constraints and logic, rather than using
an algorithm written by a programmer.
• Designed to make the computer solve a given problem without the
programmer.
Generation of Programming Languages

Programming Languages
Low Level
1GL (Machine Language)
2GL (Assembly Language)
High Level
3GL (Pascal, COBOL, FORTRAN, CC, C++, C#, Java, BASIC, Pascal,
Fortran, ALGOL, COBOL)
4GL (Perl, Python, Ruby, SQL, Unix Shell, Oracle Reports, R)
5GL (OPS5, Mercury, Prolog, LISP)
Software
Software

● Consists of various types of programs that


control the operation of computers.
● Three types of software:

System Utility Application


Software Software Software
System Software

● Software that directly controls and utilizes


computer hardware.
● Help in running application programs.
● Direct the computer what to do, when to do, and
how to do.
● Three categories of system software:
Operating Device Language
System Driver Processors
Operating System (OS)

● Software that provides an interface to


the user to use computer hardware.
● A set of programs that control and
supervise the computer hardware,
software resources, and provide
services to application software and
the users.
● A computer is of no use without an OS.
● An OS will be the first program to
loaded into memory when a computer
is switched on.
● Example of OS: Windows, Linux, Unix, ?
Functions of Operating System (OS)

Processor Management: Manage the Central Processing Unit (CPU). It


performs the allotment of CPU time to various processes

Memory Management: Loads a program into memory when it needs to be


executed and removes the program from memory when it is no longer needed.

Device Management: Helps in communication between various types of


hardware.

File Management: Manages the files, folders, and directory structures of the
computer. It is used to create, edit, copy, move and delete files.
Device Driver

● A program that controls a


particular hardware device.
● Acts as a translator between the
operating system and the
hardware devices.
● Hardware devices need their
driver to work e.g. keyboard,
mouse, printer, etc.
Languages in Computer

Source Code/Program
Language Processors

● Translator software that is used to


translate the program written in a
high-level language (or Assembly
language) into machine level
language.
● Three types of language
processors:
● Assembler
● Compiler
● Interpreter
Assembler

● Used to translate the program written in


Assembly language into machine level
language i.e. machine code.

● Source code to an Assembler contains


assembly language instructions.

● The output generated by the assembler


is the machine code that can be
executed by the computer.
Compiler

● Used to translate the high-level languages


source program/code as a whole into
machine level language.

● The source code is translated to object


code successfully if it is free of errors.

● Any errors in the source code must be


removed before the compiler can
successfully recompile the source code.

● Example: C and C++ compilers.


Assembler vs Compiler

Assembler Compiler

Compiler converts source code written


Assembler converts assembly language
in higher-level language into machine
code into machine code.
level language.

Input is source code in some higher-


Input is assembly code.
level language.

Example: GAS, GNU Example: C, C++, Java compilers


Interpreter

● A language processor that translates a single statement of a


source program into machine level language and executes it
immediately before moving on to the next line.
● The interpreter terminates its translating process at a statement
if there is an error and displays an error message.
● It can only move to the next line for execution once the error is
removed.
Compiler vs Interpreter
Compiler Interpreter

The compiler scans the whole program and The interpreter translates just one statement
translates it into machine code at once. of a program at a time into machine code.
Overall execution is fast. Overall execution is slow.
A compiler creates an intermediary object
It does not create object code.
code.
The program does not require
Programs require translation everytime users
translation/compilation everytime users run
run the program.
the program.
A compiler generates the error message only Keep translating the program until the first
after it scans the complete program. error is found.

Examples: C, C++, Java, C#, etc Examples: Python, Ruby, etc.


Linker and Loader

• Combines one or more


object files and possibly
Linker some library to create
an executable.

• Reads the executable


code into memory and
Loader tries to run the
program.
Stages of Compilation
and Execution
1
• C programs are passed to preprocessor
to resolve preprocessor directives and
Preprocessor include files in the program.

• Compiler converts C program into 2


machine language. In this step, an
Compiler object file is created.

• Linker combines various object files and


Linker
libraries to form an executable.
3

• Loader loads the executable file into the


Loader
main memory.
4
Loader
Utility Software

● Provides certain tasks that help to manage, maintain, and control


computer resources.
● Used to keep the computer system running smoothly.
● Examples:
○ Antivirus software
○ Backup software
○ Clock
Application Software

● Used to solve a particular problem or perform some specific task.


● Examples:
○ Microsoft Office
○ Photoshop
○ Music players
○ Games
Goals for next session

1. Number System
Thank You

You might also like