0% found this document useful (0 votes)
5 views

PROBLEM SOLVING USING (CH-1)

The document provides an introduction to computers and programming, explaining the key components of a computer, including hardware and software, as well as the programming process. It categorizes programming languages into low-level and high-level types, and outlines the functions of computers, which include input, processing, output, and storage. Additionally, it discusses the roles of system and application software, and the differences between compilers and interpreters in code translation.

Uploaded by

kandamadhuri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

PROBLEM SOLVING USING (CH-1)

The document provides an introduction to computers and programming, explaining the key components of a computer, including hardware and software, as well as the programming process. It categorizes programming languages into low-level and high-level types, and outlines the functions of computers, which include input, processing, output, and storage. Additionally, it discusses the roles of system and application software, and the differences between compilers and interpreters in code translation.

Uploaded by

kandamadhuri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

UNIT-1

CHAPTER 1

Introductions to Computers and Programming


Computers are electronic devices that can accept data as input, process it according to a set of
instructions, and produce output. They have become an integral part of our daily lives, from the
smartphones we carry to the complex systems that run our businesses and governments.

Programming is the process of creating a set of instructions that a computer can follow to perform
a specific task. These instructions are written in a language that the computer can understand,
known as a programming language.
Key Components of a Computer

1. Hardware: The physical components of a computer, such as the CPU, RAM, storage
devices, and input/output devices.

2. Software: The programs and applications that run on a computer, including the operating
system, software applications, and programming languages.
Types of Programming Languages

Programming languages can be broadly classified into two categories:

1. Low-level languages: These languages are closer to the machine level and require a deep
understanding of computer architecture. Examples include assembly language.

2. High-level languages: These languages are more human-readable and easier to learn. They
are often used for general-purpose programming. Examples include Python, Java, C++,
and JavaScript.
The Programming Process

1. Problem Definition: Clearly define the problem to be solved.

2. Algorithm Design: Develop a step-by-step procedure to solve the problem.

3. Coding: Write the code in a chosen programming language.

4. Testing: Test the code to ensure it works as expected and identify and fix any errors.

5. Debugging: The process of finding and fixing errors in the code.

6. Maintenance: Update and maintain the code over time to address new requirements or fix
bugs.

Basic Block Diagram of a Computer


A computer system can be represented by a simplified block diagram, illustrating the main
components and their interactions. Here's a basic representation:
Various components of computer
Key Components and Their Functions:

1. Input Units:
• Function: These devices allow users to enter data and instructions into the
computer.

Examples:

• Keyboard: For typing text and entering commands.

• Mouse: For navigating the user interface and selecting objects.

• Scanner: For digitizing images and documents.

• Microphone: For capturing audio input.

• Webcam: For capturing videos and images.

• Touchscreen: For direct interaction with the computer's display...

2. Central Processing Unit (CPU):


• Function: The "brain" of the computer, responsible for executing instructions
and performing calculations.
• Components:
▪ Control Unit (CU): Directs the operation of the processor, fetching
instructions, decoding them, and sending signals to other components.
▪ Arithmetic Logic Unit (ALU): Performs arithmetic (addition, subtraction,
multiplication, division) and logical (AND, OR, NOT) operations.

• Registers: Temporary storage locations within the CPU for holding data and
instructions during processing.
3. Memory:
• Function: Stores data and instructions temporarily or permanently.
Types:

• RAM (Random Access Memory): Volatile memory used for temporary storage of
data and programs currently in use.

• ROM (Read Only Memory): Non-volatile memory containing essential system


programs that cannot be modified by the user.

4. Output Units:
• Function: Display the results of the computer's processing.

• Examples: Monitor, printer, speakers.

5. Storage Devices:
• Function: Store data and programs permanently.
• Examples: Hard disk drives (HDDs), solid-state drives (SSDs), optical drives (CD/DVD),
USB drives.

Functions of various computers


Computers, in their essence, perform four fundamental functions:

1. Input: This is the process of receiving data from the outside world. It involves devices like
keyboards, mice, scanners, microphones, and cameras, which translate information into a
format the computer can understand.

2. Processing: This is where the computer takes the input data and manipulates it according
to a set of instructions (a program). The Central Processing Unit (CPU) is the brain of the
computer, responsible for executing these instructions and performing calculations.

3. Output: This is the presentation of the processed data in a human-readable or machine-


readable format. Output devices include monitors, printers, speakers, and network
interfaces.
4. Storage: This involves saving data for future use. Storage devices can be primary (like
RAM, for temporary storage during operation) or secondary (like hard drives, SSDs, or
external drives, for long-term storage).

These four functions work together in a continuous cycle, allowing computers to perform a vast
array of tasks, from simple calculations to complex simulations and artificial intelligence.
The following diagram shows an example of these functions.

Concepts of Hardware and Software


Hardware and software are the two fundamental components of any computer system. They work
together to enable the computer to perform tasks and interact with users

Computer Hardware
Hardware refers to the physical components of a computer. Computer Hardware is any part of the
computer that we can touch these parts. These are the primary electronic devices used to build up
the computer. Examples of hardware in a computer are the Processor, Memory Devices, Monitor,
Printer, Keyboard, Mouse, and Central Processing Unit.

Different Types of Computer Hardware

• Input Devices: Input Devices are those devices through which a user enters data and
information into the computer or simply, User interacts with the Computer. Examples of
Input Devices are Keyboard, Mouse, Scanner, etc.

• Output Devices: Output Devices are devices that are used to show the result of the task
performed by the user. Examples of Output Devices are Monitors, Printers, Speakers, etc.
• Storage Devices: Storage Devices are devices that are used for storing data and they are
also known as Secondary Storage Data. Examples of Storage Devices are CDs, DVDs,
Hard Disks, etc.

• Internal Component: Internal Components consist of important hardware devices present


in the System. Examples of Internal Components are the CPU, Motherboard, etc.

Computer Software
Software is a collection of instructions, procedures, and documentation that performs different
tasks on a computer system. We can say also Computer Software is a programming code executed
on a computer processor. The code can be machine-level code or code written for an operating
system.

Examples of software are MS- Word, Excel, PowerPoint, Google Chrome, Photoshop, MySQL,
etc.
Different Types of Computer Software

• System Software: System Software is a component of Computer Software that directly


operates with Computer Hardware which has the work to control the Computer’s Internal
Functioning and also takes responsibility for controlling Hardware Devices such as
Printers, Storage Devices, etc. Types of System Software include Operating Systems,
Language processors, and Device Drivers.

• Application Software: Application Software is the software that works the basic
operations of the computer. It performs a specific task for users. Application Software
includes Word Processors, Spreadsheets, etc. Types of Application software include
General Purpose Software, Customized Software, etc.

Types of software

Software
In a computer system, the software is basically a set of instructions or commands that tell a
computer what to do. In other words, the software is a computer program that provides a set of
instructions to execute a user’s commands and tell the computer what to do. For example
like MS-Word, MS-Excel, PowerPoint, etc.

Types of Software
It is a collection of data that is given to the computer to complete a particular task. The chart
below describes the types of software:
Above is the diagram of types of software. Now we will briefly describe each type and its subtypes:

1. System Software
• Operating System

• Language Processor

• Device Driver

2. Application Software
• General Purpose Software

• Customize Software

• Utility Software

System Software
System software is software that directly operates the computer hardware and provides the basic
functionality to the users as well as to the other software to operate smoothly. Or in other words,
system software basically controls a computer’s internal functioning and also controls hardware
devices such as monitors, printers, and storage devices, etc. It is like an interface between hardware
and user applications, it helps them to communicate with each other because hardware understands
machine language(i.e. 1 or 0) whereas user applications are work in human-readable languages
like English, Hindi, German, etc. so system software converts the human-readable language into
machine language and vice versa.
Types of System Software
It has two subtypes which are:
1. Operating System: It is the main program of a computer system. When the computer
system ON it is the first software that loads into the computer’s memory. Basically, it
manages all the resources such as computer memory, CPU, printer, hard disk, etc., and
provides an interface to the user, which helps the user to interact with the computer system.
It also provides various services to other computer software. Examples of operating
systems are Linux, Apple macOS, Microsoft Windows, etc.

2. Language Processor: As we know that system software converts the human-readable


language into a machine language and vice versa. So, the conversion is done by the
language processor. It converts programs written in high-level programming
languages like Java, C, C++, Python, etc(known as source code), into sets of instructions
that are easily readable by machines(known as object code or machine code).

3. Device Driver: A device driver is a program or software that controls a device and helps
that device to perform its functions. Every device like a printer, mouse, modem, etc. needs
a driver to connect with the computer system eternally. So, when you connect a new device
with your computer system, first you need to install the driver of that device so that your
operating system knows how to control or manage that device.

Application Software
Software that performs special functions or provides functions that are much more than the basic
operation of the computer is known as application software. Or in other words, application
software is designed to perform a specific task for end-users. It is a product or a program that is
designed only to fulfill end-users’ requirements. It includes word processors, spreadsheets,
database management, inventory, payroll programs, etc.

Types of Application Software


There are different types of application software and those are:

1. General Purpose Software: This type of application software is used for a variety of tasks and
it is not limited to performing a specific task only. For example, MS-Word, MS-Excel,
PowerPoint, etc.

2. Customized Software: This type of application software is used or designed to perform specific
tasks or functions or designed for specific organizations. For example, railway reservation
system, airline reservation system, invoice management system, etc.

3. Utility Software: This type of application software is used to support the computer
infrastructure. It is designed to analyze, configure, optimize and maintains the system, and take
care of its requirements as well. For example, antivirus, disk fragmenter, memory tester, disk
repair, disk cleaners, registry cleaners, disk space analyzer, etc.
Compiler and Interpreter
Compilers and Interpreters: The Translators of Code

In the world of programming, computers can't directly understand the code we write. They need it
to be translated into machine code, a low-level language of 0s and 1s. This is where compilers and
interpreters come into play.

Compiler

Definition: A compiler is like a translator that translates the entire source code (the code
written by the programmer) into machine code in one go, before the program is executed.

Process:

1. Source Code: The programmer writes the code in a high-level language (like C,
C++, Java).

2. Compilation: The compiler analyzes the entire source code, checks for errors, and
translates it into machine code (also known as object code or executable file).

3. Execution: The computer then executes the generated machine code.

Compiler process

Advantages:

• Faster Execution: Compiled programs generally execute much faster than interpreted
ones because the translation process is completed beforehand.

• Better Performance: Compilers can perform optimizations on the code during the
compilation process, resulting in more efficient machine code.

• Platform Independence (to some extent): Compiled code can sometimes be made to run
on different platforms with minimal modifications.

Disadvantages:
• Slower Development Cycle: The entire program needs to be recompiled after every code
change, which can be time-consuming.
• Difficult Debugging: Identifying and fixing errors can be more challenging as the
compiler might report errors after the entire program has been translated.

• Platform Dependence: While some level of portability is possible, compiled code is often
tied to a specific processor architecture.

Interpreter
Definition: An interpreter, on the other hand, translates and executes the code line by line.
It doesn't create a separate machine code file.

Process:

1. Source Code: The programmer writes the code in a high-level language (like
Python, JavaScript, Ruby).

2. Interpretation: The interpreter reads the code line by line, translates it into
machine code, and executes it immediately.

3. Execution: If there's an error in a line, the interpreter stops and reports the error.

Interpreter process

Examples

• Compiler-based languages: C, C++, C#, Java (bytecode is compiled)

• Interpreter-based languages: Python, JavaScript, Ruby, PHP


Advantages:

• Faster Development: Changes to the code can be tested immediately without the need for
a lengthy compilation process.

• Easier Debugging: Errors are identified and reported line by line, making it easier to
pinpoint the source of the problem.
• Platform Independence: Interpreted code is generally more portable across different
operating systems.
Disadvantages:
• Slower Execution: Interpreted programs typically run slower than compiled ones due to
the overhead of translation during execution.

• Less Efficient: Interpreters generally cannot optimize code to the same extent as
compilers, leading to less efficient execution.

• Requires Interpreter: The interpreter program must be present on the machine to run the
interpreted code.

Concepts of Machine Level


What is Machine Language

Machine language is a low-level programming language that consists of binary bits i.e. only 0 and
1. The data present in binary form is the reason for its fast execution. In Machine language,
instructions are directly executed by the CPU. Machine language is also known as object code or
machine code. Machine language is binary language.

Machine language

How Machine Code is Created

• Assembly Language: A slightly higher-level language called assembly language uses


mnemonics (short codes) to represent machine code instructions.

• Assemblers: Special programs called assemblers translate assembly language code into
machine code.

Needs of Machine Language

As a human, we write code in high level language. The programming language which we use to
write codes such as C, C++ and java are high level languages. High level language is not
understood by computer directly so it is converted into low level machine language to understand
the meaning of code and perform execution. Computers compile the code written by us and
translate into machine code and then execute it. Computers are only able to understand machine
language.

Features of Machine Language


• Machine language is a low level language.
• Machine language consist of only 0 and 1 bits.
• Machine languages are platform dependent.

• It is nearly impossible to learn machine language for humans because it requires a lot of
memorization.

• Machine language is used to create and construct drivers as well.

Machine Language Instruction Components

Machine language consists of two instruction components :

1. Operand(s)

The operand(s) represents the data that the operation must be performed on. This data can
take various forms, depending on the processor's architecture. This can be a register
containing a value, a memory address pointing to a location in memory where the data is
stored, or a constant value embedded within the instruction itself.

2. Opcode

The opcode (Operation code) represents the operation that the processor must perform.
This indicates that the instruction is an arithmetic operation such as addition, subtraction,
multiplication, or division.

Advantages of Machine Language

• Machine languages are faster in execution because they are in binary form.

• Machine language does not need to be translated , because it is already present in simple
binary form.

• The CPU directly executes the machine language.

• The evolution of the computer system and operating system over the time period is due to
machine language.
• Machine languages are used in developing a high-grade computer system.

Disadvantages of Machine Language

• Machine language are complex to understand and memorize.

• Writing codes in machine language is time-consuming.


• It is very difficult to resolve bugs and errors present in the codes and programs.

• Codes written in machine languages are more prone to error.

• Machine languages are not easy to modify.


• Machine language are platform Independent.
Assembly language and High-level programming
Programming languages can be broadly classified into two categories: Assembly Language and
High-Level Languages.

Assembly Language:
Assembly language is a low-level programming language that provides a way for humans to
communicate directly with computer hardware. It's a step above machine code, which is the raw
binary instructions that the computer's processor understands.

• Low-level language: It's closer to machine code, the raw instructions understood by the
computer's processor.

• Uses mnemonics: Instead of binary code, it uses short abbreviations (mnemonics) to


represent machine instructions.

• Processor-specific: Assembly language instructions are specific to a particular type of


processor (e.g., x86, ARM).

• Direct hardware control: Provides fine-grained control over hardware resources like
memory and registers.
Examples: x86 assembly, ARM assembly

Advantages

• Execution of code is efficient

• Low-level operations can be performed

• High control over Hardware

Disadvantages

• More Complex
• More time consuming
• Lack of Portability
High-Level Language:

It is a machine-independent language. It enables a user to write a program in a language that


resembles English words and familiar mathematical symbols, COBOL was the first high-level
language. Examples of high-level language are python, c#, etc.

• Human-readable: Uses English-like syntax and constructs, making them easier to write
and understand.
• Platform-independent (mostly): Programs written in high-level languages can often be
compiled to run on different types of computers.
• Abstraction: Hides low-level details of the hardware, allowing programmers to focus on
the problem at hand.

• Examples: C, C++, Java, Python, JavaScript, etc.


Advantages

• Increase Readability

• Portability

• Faster Development

Disadvantages

• Slower Execution

• Memory Usage
• Less Control Over Hardware

Key Differences
Flowcharts and algorithms
Algorithm
The word Algorithm means “a process or set of rules to be followed in calculations or other
problem-solving operations”. Therefore Algorithm refers to a set of rules/instructions that define
step-by-step how a work is to be executed in order to get the expected results. Let’s take a look at
an example for a better understanding. As programmers, we are all aware of the Linear Search
program

Key Characteristics:
• Finiteness: An algorithm must eventually terminate after a finite number of steps.

• Definiteness: Each step in the algorithm must be precisely defined and unambiguous.
• Input: An algorithm may or may not take input.

• Output: An algorithm must produce an output.

• Effectiveness: Each step in the algorithm must be feasible and executable.

Flowcharts
A flowchart is a diagrammatic representation of an algorithm. It uses various shapes to
depict different types of operations and arrows to indicate the flow of control between
them.

Common Symbols:

• Oval: Represents the start or end of the flowchart.

• Rectangle: Represents a process or action.


• Diamond: Represents a decision point (e.g., a conditional statement).

• Parallelogram: Represents input or output.

Example: - Finding the Largest of Three Numbers

Algorithm:
1. Read three numbers: num1, num2, and num3.

2. If num1 is greater than num2:

If num1 is greater than num3:

▪ Largest = num1

Else:

▪ Largest = num3

3. Else:
If num2 is greater than num3:
▪ Largest = num2

Else:

▪ Largest = num3

4. Print the value of Largest.


Flowchart:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy