0% found this document useful (0 votes)
18 views25 pages

01 PPS

The document provides an introduction to programming, covering the basics of computer systems, hardware, software, and programming languages. It explains key components such as the CPU, input/output devices, and the roles of compilers and interpreters. Additionally, it discusses algorithms and flowcharts as essential tools for problem-solving in programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views25 pages

01 PPS

The document provides an introduction to programming, covering the basics of computer systems, hardware, software, and programming languages. It explains key components such as the CPU, input/output devices, and the roles of compilers and interpreters. Additionally, it discusses algorithms and flowcharts as essential tools for problem-solving in programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Programming for Problem Solving

(BE01000121)

UNIT: I Introduction to Programming

Prof. Pinal Mistry


Information Technology Department
Mob: 8128138239
Email: [email protected]
Topic To Be Covered

➔ Basics of Computers:
◆ Overview of computer systems
◆ Hardware, and software
➔ Introduction to Programming Languages:
◆ Types of programming languages
◆ Language translators (compilers, interpreters)
➔ Flowcharts and Algorithms:
◆ Basics of creating flowcharts and writing algorithms for problem-solving
What is Computer?
❏ A computer is an electronic device that can be programmed to accept data (input),
process it and generate result (output). A computer along with additional hardware
and software together is called a computer system.
❏ A computer is an electronic device that is designed to process, store, and retrieve
information.
❏ It can perform a variety of tasks based on instructions provided by a user or a
program.
Components of Computer System
Central Processing Unit (CPU)
❏ It is the electronic circuitry of a computer that carries out the actual processing and usually
referred as the brain of the computer. It is commonly called processor also.
❏ The CPU is given instructions and data through programs. The CPU then fetches the
program and data from the memory and performs arithmetic and logic operations as per the
given instructions and stores the result back to memory.
❏ CPU has two main components — Arithmetic Logic Unit (ALU) and Control Unit (CU).
ALU performs all the arithmetic and logic operations that need to be done as per the
instruction in a program. CU controls sequential instruction execution, interprets
instructions and guides data flow through the computer’s memory, ALU and input or output
devices.
Input Devices
❏ The devices through which control signals are sent to a computer are termed as input
devices.
❏ These devices convert the input data into a digital form that is acceptable by the computer
system.
❏ Some examples of input devices include keyboard, mouse, scanner, touch screen, etc.,
❏ Data entered through input device is temporarily stored in the main memory (also called
RAM) of the computer system.
❏ For permanent storage and future use, the data as well as instructions are stored permanently
in additional storage locations called secondary memory.
Output Devices
❏ The device that receives data from a computer system for display, physical production, etc.,
is called output device.
❏ It converts digital information into human understandable form.
❏ For example, monitor, projector, headphone, speaker, printer, etc.
How Computer System work?
❏ A computer system processes and executes instructions through key components working
together.
❏ It starts with user input via devices like a keyboard or mouse, which is processed by the
CPU.
❏ The CPU uses memory (RAM, cache, storage) to fetch, decode, and execute instructions.
❏ After processing, the results are sent to output devices (e.g., monitor, printer).
❏ Software, including the operating system, manages resources and tasks.
❏ Additionally, the system can communicate with other computers over networks to access
remote data and interact globally.
Hardware
❏ Hardware refers to the physical components of a computer system.
❏ These are the tangible parts that you can see and touch.
❏ Hardware provides the infrastructure for software to run and processes the data.
❏ Examples of hardware: CPU, RAM, hard drive, keyboard, monitor.
Software
❏ Software refers to the programs and operating systems that tell the hardware what to do
and how to do it.
❏ Unlike hardware, software is intangible and consists of written code that can be executed
by the CPU.
❏ The sole purpose of a software is to make the computer hardware useful and operational.
❏ Types of Software:
● Application Software
● System Software
System Software:

● Manages the hardware and provides a platform for running application software. The most
important type of system software is the operating system (OS).
● Examples: Windows, macOS, Linux, iOS, Android.
● Other examples of system software include device drivers, which allow the operating
system to interact with specific hardware devices.
Application Software:

● These are programs designed to perform specific tasks for the user. They rely on the
operating system and hardware to function.
● Examples: Microsoft Word, Adobe Photoshop, web browsers (e.g., Chrome, Firefox),
games, and media players.
Introduction to Programming Languages
● A programming language is a formal language used to communicate instructions to a
computer.
● These languages are used to create software programs, scripts, and algorithms that control
how a computer behaves.
● Programming languages allow humans to write code that the computer can understand and
execute.
● Program: A program is a set of instructions written in a programming language that tells
a computer how to perform a specific task or solve a problem.
Types of Programming Languages
Machine Level Language (Low-Level Language):

● Machine Level Language is the lowest level of programming language, consisting entirely
of binary code (0s and 1s).
● It is the only language directly understood by the computer's Central Processing Unit
(CPU), as the CPU operates on binary data.
● Machine language instructions are represented as sequences of binary digits (bits), and
each instruction corresponds to an operation performed by the computer's hardware.
● Use Cases: Embedded systems, operating systems, device drivers, and performance-
critical applications.
High-Level Language:

● A High-Level Language (HLL) is a programming language that is designed to be easy for


humans to read, write, and understand.
● These languages abstract away the underlying hardware details and are much closer to
natural language, making them easier to use compared to low-level languages.
● High-level languages are machine-independent, meaning the same program can run on
different computer systems with minimal modifications.
● Example: C, C++ , Java, Python
● Use Case: Web development, software development, scientific computing, artificial
intelligence, etc.
Assembly Language:

● It uses short descriptive words (MNEMONIC) to represent each of the machine language
instructions.
● It requires a translator knows as assembler to convert assembly language into machine
language so that it can be understood by the computer.
● Examples: 8085 Instruction set
Compiler, Interpreter, and Assembler
Compiler:
● A Compiler is a software that typically takes a high level language (Like C++ and
Java) code as input and converts the input to a lower level language at once. It lists
all the errors if the input code does not follow the rules of its language. This process
is much faster than interpreter but it becomes difficult to debug all the errors together
in a program.
● A compiler is a translating program that translates the instructions of high level
language to machine level language.
Compiler, Interpreter, and Assembler
Interpreter:
● An interpreter translates and executes the source code line by line or statement by
statement.
● It doesn't produce a separate executable file. Instead, it runs the program directly,
translating each line of code into machine code at runtime.
● Errors are identified and reported immediately, which makes debugging easier.
● Example: Python, Ruby, JavaScript.
Compiler, Interpreter, and Assembler
Assembler:
● An assembler translates assembly language (a low-level programming language
closely related to machine code) into machine code or binary code, which the CPU
can execute.
● Assembly language is specific to the computer architecture, so an assembler for one
system may not work for another.
● The output of an assembler is an object file, which can later be linked to create an
executable program.
● Example: Assembly language programs on a specific architecture (x86 assembly,
ARM assembly).
Algorithm
❏ An algorithm in programming is a step-by-step procedure or set of instructions
designed to perform a specific task or solve a problem.
❏ It provides a clear and systematic way to approach a problem and can be
implemented in any programming language.
❏ An algorithm typically takes some input, such as data from the user or a file.
❏ It produces some output based on the input and its operations.
❏ Algorithms should aim to perform tasks in the least amount of time or space required,
though complexity may vary.
How to Write Algorithm
1. Understand the Problem
2. Define the input & Output
3. Break Down the Problem
4. Write the Steps in Order
5. Use Simple Language
6. End the Algorithm
Flowchart
❏ A flowchart is a graphical representation of an algorithm or a process.
❏ It uses symbols and arrows to represent the flow of steps in a procedure or system.
❏ Flowcharts are commonly used to visualize the logic and decision-making process in
programming or system design.
❏ Each operation within a program corresponds to a specific symbol on the flowchart.
By connecting these symbols with arrows that indicate the path from one operation to
another, a flowchart visualizes how data moves throughout a program, making it
easier to understand and debug.
Symbol used in Flowchart

Oval: Represents start and end points Parallelogram: Symbolizes input/output operations

start/end
input/output

Rectangle: Indicates a processing step


Arrow Lines: Shows the direction of flow between
different operations
Process

Diamond: Used for decision-making Operations

Decision
Algorithm 1: Add two numbers entered by the user

Start
Step 1: Start
Step 2: Input: Two numbers a and b. Input: a,b

Step 3: Add: Calculate the sum sum = a + b.


Step 4: Output: Display the result sum. sum=a+b
Step 5: End

Output: sum

End
Algorithm 2: Check number is even or odd

Step 1: Start
Step 2: Input: A number a.
Step 3: Check: if n mod 2 ==0
If true, Output: "Even"
Else, Output: "Odd"
Step 4: End

You might also like