SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
PPS
Unit – 1
Introduction To Programming
1.1 Introduction To Components Of A Computer System (Disks, Memory, Processor,
Where A Program Is Stored And Executed Operating System, Compilers Etc).
Disks:
Generally, a disk is a a round plate on which data can be encoded. There are two basic
types of disks: magnetic disks and optical disks.
Magnetic Disks
In magnetic disks, the data is encoded as microscopic magnetized needles on the disk's
surface. You can record and erase data on a magnetic disk any number of times
Magnetic disks come in a number of different forms:
 Floppy disk: A typical 5¼-inch floppy disk can hold 360K or 1.2MB megabytes.
3½-inch floppies normally store 720K, 1.2MB or 1.44MB of data. Floppy disks or
obsolete today.
 Harddisk :Hard disks can store anywhere from 20MB to more than 1-TB (terabyte).
Hard disks are also from 10 to 100 times faster than floppy disks.
 Removablecartridge : Removable cartridges are hard disks encased in a metal or
plastic cartridge, so you can remove them just like a floppy disk. Removable
cartridges are fast, though usually not as fast as fixed hard disks.
Memory:
A memory is used to store data and instructions. Computer memory is the storage
space in the computer, where data is to be processed and instructions required for
processing are stored. The memory is divided into large number of small parts called
cells. Each location or cell has a unique address, which varies from zero to memory size
minus one.
For example, if the computer has 64k words, then this memory unit has 64 * 1024 =
65536 memory locations. The address of these locations varies from 0 to 65535.
Memory is primarily of three types −
 Cache Memory
 Primary Memory/Main Memory
 Secondary Memory
Cache Memory
Cache memory is a high -speed semiconductor memory which can speed up the CPU.
It acts as a buffer between the CPU and the main memory. It is used to hold those parts
of data and program which are most frequently used by the CPU. The parts of data and
programs are transferred from the disk to cache memory by the operating system, from
where the CPU can access them.
Advantages
The advantages of cache memory are as follows −
 Cache memory is faster than main memory.
 It consumes less access time as compared to main memory.
 It stores the program that can be executed within a short period of time.
 It stores data for temporary use.
Disadvantages
The disadvantages of cache memory are as follows −
 Cache memory has limited capacity.
 It is too expensive.
Primary Memory (Main Memory)
Primary memory holds only those data and instructions on which the computer is
currently working. It has a limited capacity and data is lost when power is switched off.
It is generally made up of semiconductor device. These memories are not as fast as
registers. The data and instruction required to be processed resides in the main
memory. It is divided into two subcategories RAM and ROM.
Characteristics of Main Memory
 These are semiconductor memories.
 It is known as the main memory.
 Usually volatile memory.
 Data is lost in case power is switched off.
 It is the working memory of the computer.
 Faster than secondary memories.
 A computer cannot run without the primary memory.
Secondary Memory
This type of memory is also known as external memory or non-volatile. It is slower than
the main memory. These are used for storing data/information permanently. CPU
directly does not access these memories, instead they are accessed via input-output
routines. The contents of secondary memories are first transferred to the main memory,
and then the CPU can access it. For example, disk, CD-ROM, DVD, etc.
Characteristics of Secondary Memory
 These are magnetic and optical memories.
 It is known as the backup memory.
 It is a non-volatile memory.
 Data is permanently stored even if power is switched off.
 It is used for storage of data in a computer.
 Computer may run without the secondary memory.
 Slower than primary memories.
Processor:
A processor (CPU) is the logic circuitry that responds to and processes the basic
instructions that drive a computer. The CPU is the main integrated circuitry (IC) chip in a
computer, as it is responsible for interpreting most of computers commands. CPUs will
perform most basic arithmetic, logic, and I/O operations, as well as allocate commands
for other chips and components running in a computer.
The basic elements of a processor include:
 The arithmetic logic unit (ALU), which carries out arithmetic and logic operations
on the operands in instructions.
 The floating -point unit (FPU), also known as a math coprocessor or numeric
coprocessor, a specialized co-processor that manipulates numbers more quickly
than the basic microprocessor circuitry can.
 Registers, which hold instructions and other data. Registers supply operands to the
ALU and store the results of operations.
 L1 and L2 cache memory. Their inclusion in the CPU saves time compared to
having to get data from random access memory (RAM).
CPU Operations
The four primary functions of a processor are fetch, decode, execute and write back.
Fetch- is the operation which receives instructions from program memory from a
systems RAM.
Decode- is where the instruction is converted to understand which other parts of the
CPU are needed to continue the operation. This is performed by the instruction decoder
Execute- is where the operation is performed. Each part of the CPU that is needed is
activated to carry out the instructions.
Program stored and executed operating system:
Whenever you save your program(anything) into a file (any kind of file, say ‘add.c’), it
automatically gets stored in the secondary storage that is the hard disk. The Operating
System’s kernel (kernel’s File management system) does it for you.
When you run program, it is loaded into the main/primary memory of the computer
called RAM (the entire program is transferred to the RAM, by a small program called
the loader (which often comes with the compiler i.e. is a part of the compiler).
The program instructions are executed in the ALU (Arithmetic-Logic Unit) of the CPU (in
its registers like the Accumulator). In order to execute the instructions , the CPU
fetches the values of the variables (say, int a =10; int b =20;) in the program from the
RAM, and stores the results also in the RAM (int sum =30;), which is then sent to the
output buffer stream (stdout) , which prints the results (30) on the computer
console/terminal, the Windows kernel (kernel’s I/O management system) does the
printing .
Compilers:
Compiler is a program that translates source code into object code. The compiler
derives its name from the way it works, looking at the entire piece of source code and
collecting and reorganizing the instructions. Thus, a compiler differs from
an interpreter, which analyses and executes each line of source code in succession,
without looking at the entire program. The advantage of interpreters is that they can
execute a program immediately. Compilers require some time before an executable
program emerges. However, programs produced by compilers run much faster than the
same programs executed by an interpreter.
Every high- level programming language comes with a compiler. In effect, the compiler
is the because it defines which instructions are acceptable.
Because compilers translate source code into object code, which is unique for each type
of computer many compilers are available for the same language.
1.2 Idea Of Algorithm: Steps To Solve Logical And Numerical Problems
An algorithm is the finite set of English statements which are designed to accomplish the
specific task. Study of any algorithm is based on the following four criteria
1. Design of algorithm:This is the first step in the creation of an algorithm. Design of
algorithm includes the problem statement which tell user about the area for which
algorithm is required. After problem statement next important thing required is the
information about available and required resources. The last thing required in design of
algorithm phase is information about the expected output.
2. Validation of algorithm: Once an algorithm is designed , it is necessary to validate it
for several possible input and make sure that algorithm is providing correct output for
every input. This process is known as algorithm validation. The purpose of the validation
is to assure us that this algorithm will work correctly independently of the issues
concerning the programming language it will eventually be written in.
3. Analysis of algorithm: Analysis of algorithms is also called as performance analysis.
This phase refers to the task of determining how much computing time and storage an
algorithm requires. The efficiency is measured in best case, worst case and average
case analysis.
4. Testing of algorithm:This phase is about to testing of a program which coded as per
the algorithm. Testing of such program consists of two phases:
 Debugging: It is the process of executing programs on sample data sets to determine
whether faulty results occur or not and if occur, to correct them.
 Profiling : Profiling or performance measurement is the process of executing a correct
program on data sets and measuring the time and space it takes to compute the
result
Characteristics of an algorithm
 Input: Algorithm must accept zero or more inputs.
 Output: Algorithm must provide at least one quantity.
 Definiteness: Algorithm must consist of clear and unambiguous instruction.
 Finiteness: Algorithm must contain finite set of instruction and algorithm will terminates
after a finite number of steps.
 Effectiveness: Every instruction in algorithm must be very basic and effective.
Uses of algorithm
 Algorithm provide independent layout of the program.
 It is easy to develop the program in any desired language with help of layout.
 Algorithm representation is very easy to understand.
 To design algorithm there is no need of expertise in programming language.
1.3 Representation Of Algorithm: Flowchart/Pseudo Code With Examples. From
Algorithms To Programs
There are three ways to represent an algorithm. Consider the following algorithm of
addition of two numbers
Step 1 : Start
Step 2 :Read a number, say x and y
Step 3 :Add x and y
Step 4 :Display Addition
Step 5 :Stop
1. Flowcharts: A flow chart is a diagrammatic / pictorial representation of an algorithm.
It is the simplest way of representation of algorithm. Initially an algorithm is represented
in the form of flowchart and then flowchart is given to programmer to express it in some
programming language. Logical error detection is very easy in flowchart as it shows the
flow of operations in diagrammatic form. Once flowchart is ready it is very easy to write
a program in terms of statements of a programming language. Following are the
symbols used in designing the flowcharts.
2. Pseudo code: Pseudo code is the combination of English statements with
programming methodology. In pseudo code, there is no restriction of following the
syntax of the programming language. Pseudo codes cannot be compiled. It is just a
previous step of developing a code for given algorithm.
3. Program: In this way of representation, complete algorithm is represented using
some programming language by following the complete syntax of programming
language.
Sr.
No.
Name of
Symbol
Symbol Meaning / Purpose
1. Terminal To indicate START / STOP.
Usually it is the first symbol
and last symbol used in
program logic.
2. Input /
Output
Statement
To indicate input / output of
Data
3. Processing
Statement
To indicate the processing of
instructions.
4.
Decision
Box
To indicate decision making
and a branch to one or more
alternatives.
5. Flow Lines To indicate the direction of
flow of information.
6. Connector It is used when flowchart
becomes long and need to be
continued. Shows the
continuity of the algorithm on
the next page.
1.4 Source Code
Source code is the list of human-readable instructions that a programmer writes—often
in a word processing program—when he is developing a program. The source code is
run through to turn it in compiler to machine code called as object code.
1.5 Variables (With Data Types) Variables And Memory Locations
Variables are the names you give to computer memory locations which are used to store
values in a computer program.
Here are the following three simple steps −
 Create variables with appropriate names.
 Store your values in those two variables.
 Retrieve and use the stored values from the variables.
When creating a variable, we need to declare the data type it contains.
Programming languages define data types differently.
For example, almost all languages differentiate between ‘integers’ (or whole
numbers, eg 12), ‘non-integers’ (numbers with decimals, eg 0.24), and ‘characters’
(letters of the alphabet or words).
 char – a single 16-bit Unicode character, such as a letter, decimal or punctuation
symbol.
 boolean – can have only two possible values: true (1) or false (0). This data type is
useful in conditional statements.
 byte - has a minimum value of -128 and a maximum value of 127 (inclusive).
 short– has a minimum value of -32,768 and a maximum value of 32,767
 int: – has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647
(inclusive).
 long – has a minimum value of -9,223,372,036,854,775,808 and a maximum value of
9,223,372,036,854,775,807 (inclusive).
 float – a floating point number with 32-bits of precision
 double – this is a double precision floating point number.
1.6 Type Casting/Type Conversion
Type casting refers to changing variable of one data type into another. The compiler
will automatically change one type of data into another. For instance, if you assign an
integer value to a floating-point variable, the compiler will convert the int to a float.
Casting allows you to make this type conversion explicit, or to force it when it would
not normally happen.
Type conversion in c can be classified into the following two types:
1. Implicit Type Conversion
When the type conversion is performed automatically by the compiler
without programmers intervention, such type of conversion is known as implicit type
conversion or type promotion.
int x;
for(x=97; x<=122; x++)
{
printf("%c", x); /*Implicit casting from int to char thanks to %c*/
}
2. Explicit Type Conversion
The type conversion performed by the programmer by posing the data type of the
expression of specific type is known as explicit type conversion. The explicit type
conversion is also known as type casting.
Type casting in c is done in the following form:
(data_type)expression;
where, data_type is any valid c data type, and expression may be constant, variable
or expression.
For example,
int x;
for(x=97; x<=122; x++)
{
printf("%c", (char)x); /*Explicit casting from int to char*/
}
The following rules need to be followed while converting the expression from one
type to another to avoid the loss of information:
 All integer types to be converted to float.
 All float types to be converted to double.
 All character types to be converted to integer.
Example
Consider the following code:
int x=7, y=5 ;
float z;
z=x/y; /*Here the value of z is 1*/
If we want to get the exact value of 7/5 then we need explicit casting from int to float:
int x=7, y=5;
float z;
z = (float)x/(float)y; /*Here the value of z is 1.4*/
1.7 Run Time Environment (Static, Dynamic Location)
Stands for "Runtime Environment." As soon as a software program is executed, it is in
a run time state. In this state, the program can send instructions to the computer's
processor and access the computer's memory and other system resources.
When software developers write programs, they need to test them in the runtime
environment. Therefore, software development programs often include an RTE
component that allows the programmer to test the program while it is running. This
allows the program to be run in an environment where the programmer can track
the instructions being processed by the program and debug any errors that may
arise. If the program crashes, the RTE software keeps running and may provide
important information about why the program crashed.
1.8 Storage Classes (Auto, Register, Static, Extern)
A storage class is used to describe the following things:
 The variable scope.
 The location where the variable will be stored.
 The initialized value of a variable.
 A lifetime of a variable.
1.9 Syntax And Logical Errors In Compilation
A syntax error is an error in the source code of a program. Since computer programs
must follow strict syntax to compile correctly, any aspects of the code that do not
conform to the syntax of the programming language will produce a syntax error.
• Spelling mistakes
• Missing out quotes
• Missing out brackets
• Using upper case characters in key words e.g. IF instead of if
• Missing out a colon or semicolon at end of a statement
• Using tokens in the wrong order A logic error (or logical error) is a ‘bug’ or
mistake in a program’s source code that results in incorrect or unexpected
behaviour. It is a type of runtime error that may simply produce the wrong output or
may cause a program to crash while running.
1.10 Object and Executable Code

Source code is the C program that you write in your editor and save with a ‘ .C ‘
extension which is un-compiled when written for the first time or whenever a
change is made in it and saved.
Object code is the output of a compiler after it processes the source code. The
object code is usually a machine code, also called a machine language, which can
be understood directly by a specific type of CPU. However, some compilers are
designed to convert source code into an assembly language or some other another
programming language. An assembly language is a human-readable notation using
the mnemonics in the ISA of that particular CPU.
Executable (also called the Binary) is the output of a linker after it processes
the object code. A machine code file can be immediately executable, runnable as
a program , or it might require linking with other object code files for
example libraries to produce a complete executable program.

More Related Content

What's hot (20)

C Programming: Control Structure
C Programming: Control Structure
Sokngim Sa
 
Constants in C Programming
Constants in C Programming
programming9
 
C program
C program
AJAL A J
 
fundamentals of c
fundamentals of c
Vijayalaxmi Wakode
 
Basic structure of c programming
Basic structure of c programming
TejaswiB4
 
C programming language tutorial
C programming language tutorial
javaTpoint s
 
Files in c++
Files in c++
Selvin Josy Bai Somu
 
Pointers in c language
Pointers in c language
Tanmay Modi
 
Strings in C language
Strings in C language
P M Patil
 
Storage classes in C
Storage classes in C
Self employed
 
Character Arrays and strings in c language
Character Arrays and strings in c language
mallikavin
 
Unit 3. Input and Output
Unit 3. Input and Output
Ashim Lamichhane
 
Conditional operators
Conditional operators
BU
 
c-programming
c-programming
Zulhazmi Harith
 
OpenGurukul : Language : C Programming
OpenGurukul : Language : C Programming
Open Gurukul
 
Function in C Programming
Function in C Programming
Anil Pokhrel
 
String functions in C
String functions in C
baabtra.com - No. 1 supplier of quality freshers
 
Jumping statements
Jumping statements
Suneel Dogra
 
CONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGE
Ideal Eyes Business College
 
Unit 2. Elements of C
Unit 2. Elements of C
Ashim Lamichhane
 
C Programming: Control Structure
C Programming: Control Structure
Sokngim Sa
 
Constants in C Programming
Constants in C Programming
programming9
 
Basic structure of c programming
Basic structure of c programming
TejaswiB4
 
C programming language tutorial
C programming language tutorial
javaTpoint s
 
Pointers in c language
Pointers in c language
Tanmay Modi
 
Strings in C language
Strings in C language
P M Patil
 
Storage classes in C
Storage classes in C
Self employed
 
Character Arrays and strings in c language
Character Arrays and strings in c language
mallikavin
 
Conditional operators
Conditional operators
BU
 
OpenGurukul : Language : C Programming
OpenGurukul : Language : C Programming
Open Gurukul
 
Function in C Programming
Function in C Programming
Anil Pokhrel
 
Jumping statements
Jumping statements
Suneel Dogra
 

Similar to PPS 1.1.INTRODUCTION TO COMPONENTS OF A COMPUTER SYSTEM (DISKS, MEMORY, PROCESSOR, WHERE A PROGRAM IS STORED AND EXECUTED, OPERATING SYSTEM (20)

11th-CS system overview ppt chapter-01.pdf
11th-CS system overview ppt chapter-01.pdf
ravimeera74
 
Lecture 2 - Computer Hardware & Operating Systems
Lecture 2 - Computer Hardware & Operating Systems
Jack Hyman
 
Pankaj kumar
Pankaj kumar
Online Assignment Help
 
18. the components of the system unit
18. the components of the system unit
Zambales National High School
 
Unit 1_Fundamentals of Computing.ppttttt
Unit 1_Fundamentals of Computing.ppttttt
jayasmruthicmscse
 
EDITED JNNIE_Sample Lecture PPT-Template.pptx
EDITED JNNIE_Sample Lecture PPT-Template.pptx
rajar350756
 
The system unit
The system unit
University Institute of Management sciences
 
The system unit ch # 4
The system unit ch # 4
Rana Usman Sattar
 
Components of a computer
Components of a computer
DibyenduBiswas31
 
chapter2.pptxttttttttttttttttttttttttttt
chapter2.pptxttttttttttttttttttttttttttt
12091yeasmin
 
Components of a digital computer.ppt
Components of a digital computer.ppt
DibyenduBiswas31
 
20200909-XI-CSC-Computer chapter-1-1 of 6-Ppt.pptx
20200909-XI-CSC-Computer chapter-1-1 of 6-Ppt.pptx
AhsanHabib141715
 
Computer system and organization types of memory
Computer system and organization types of memory
samreen82
 
CH - 4 central processing unit & memory devices.pptx
CH - 4 central processing unit & memory devices.pptx
PragatiKachhi1
 
Cpu
Cpu
Muhammad Ramzan
 
COMPUTER ORGANIZATION for beginner and a
COMPUTER ORGANIZATION for beginner and a
souviksaha568212
 
computer devices and memory unit 2 notes.pdf
computer devices and memory unit 2 notes.pdf
shubhangisonawane6
 
Computer-Processing-Devices.pdf
Computer-Processing-Devices.pdf
DKGAUTAMgautam
 
CPU
CPU
BIT19227Usmanjavaid
 
ICT - Lecture Notes 3.pdf
ICT - Lecture Notes 3.pdf
HonKencyTress
 
11th-CS system overview ppt chapter-01.pdf
11th-CS system overview ppt chapter-01.pdf
ravimeera74
 
Lecture 2 - Computer Hardware & Operating Systems
Lecture 2 - Computer Hardware & Operating Systems
Jack Hyman
 
Unit 1_Fundamentals of Computing.ppttttt
Unit 1_Fundamentals of Computing.ppttttt
jayasmruthicmscse
 
EDITED JNNIE_Sample Lecture PPT-Template.pptx
EDITED JNNIE_Sample Lecture PPT-Template.pptx
rajar350756
 
chapter2.pptxttttttttttttttttttttttttttt
chapter2.pptxttttttttttttttttttttttttttt
12091yeasmin
 
Components of a digital computer.ppt
Components of a digital computer.ppt
DibyenduBiswas31
 
20200909-XI-CSC-Computer chapter-1-1 of 6-Ppt.pptx
20200909-XI-CSC-Computer chapter-1-1 of 6-Ppt.pptx
AhsanHabib141715
 
Computer system and organization types of memory
Computer system and organization types of memory
samreen82
 
CH - 4 central processing unit & memory devices.pptx
CH - 4 central processing unit & memory devices.pptx
PragatiKachhi1
 
COMPUTER ORGANIZATION for beginner and a
COMPUTER ORGANIZATION for beginner and a
souviksaha568212
 
computer devices and memory unit 2 notes.pdf
computer devices and memory unit 2 notes.pdf
shubhangisonawane6
 
Computer-Processing-Devices.pdf
Computer-Processing-Devices.pdf
DKGAUTAMgautam
 
ICT - Lecture Notes 3.pdf
ICT - Lecture Notes 3.pdf
HonKencyTress
 
Ad

More from Sitamarhi Institute of Technology (20)

STET 2025 900+ Computer MCQs in English PDF (studynotes.online).pdf
STET 2025 900+ Computer MCQs in English PDF (studynotes.online).pdf
Sitamarhi Institute of Technology
 
DeepSeek vs. ChatGPT - The Battle of AI Titans.pdf
DeepSeek vs. ChatGPT - The Battle of AI Titans.pdf
Sitamarhi Institute of Technology
 
METHODS OF CUTTING COPYING HTML BASIC NOTES
METHODS OF CUTTING COPYING HTML BASIC NOTES
Sitamarhi Institute of Technology
 
introduction Printer basic notes Hindi and English
introduction Printer basic notes Hindi and English
Sitamarhi Institute of Technology
 
Beginners Guide to Microsoft OneDrive 2024–2025.pdf
Beginners Guide to Microsoft OneDrive 2024–2025.pdf
Sitamarhi Institute of Technology
 
ChatGPT Foundations rompts given for each topic in both personal and business...
ChatGPT Foundations rompts given for each topic in both personal and business...
Sitamarhi Institute of Technology
 
Google Drive Mastery Guide for Beginners.pdf
Google Drive Mastery Guide for Beginners.pdf
Sitamarhi Institute of Technology
 
Chat GPT 1000+ Prompts - Chat GPT Prompts .pdf
Chat GPT 1000+ Prompts - Chat GPT Prompts .pdf
Sitamarhi Institute of Technology
 
Smart Phone Film Making.filmmaking but feel limited by the constraints of exp...
Smart Phone Film Making.filmmaking but feel limited by the constraints of exp...
Sitamarhi Institute of Technology
 
WhatsApp Tricks and Tips - 20th Edition 2024.pdf
WhatsApp Tricks and Tips - 20th Edition 2024.pdf
Sitamarhi Institute of Technology
 
Mastering ChatGPT for Creative Ideas Generation.pdf
Mastering ChatGPT for Creative Ideas Generation.pdf
Sitamarhi Institute of Technology
 
BASIC COMPUTER CONCEPTSMADE BY: SIR SAROJ KUMAR
BASIC COMPUTER CONCEPTSMADE BY: SIR SAROJ KUMAR
Sitamarhi Institute of Technology
 
MS Word tutorial provides basic and advanced concepts of Word.
MS Word tutorial provides basic and advanced concepts of Word.
Sitamarhi Institute of Technology
 
BELTRON_PROGRAMMER 2018 and 2019 previous papers
BELTRON_PROGRAMMER 2018 and 2019 previous papers
Sitamarhi Institute of Technology
 
CORPORATE SOCIAL RESPONSIBILITY CSR) through a presentation by R.K. Sahoo
CORPORATE SOCIAL RESPONSIBILITY CSR) through a presentation by R.K. Sahoo
Sitamarhi Institute of Technology
 
Enhancing-digital-engagement-integrating-storytelling-
Enhancing-digital-engagement-integrating-storytelling-
Sitamarhi Institute of Technology
 
business-with-innovative email-marketing-solution-
business-with-innovative email-marketing-solution-
Sitamarhi Institute of Technology
 
beltron-programmer-2023-previous-year-question.pdf
beltron-programmer-2023-previous-year-question.pdf
Sitamarhi Institute of Technology
 
Beltron Programmer IGNOU-MCA-NEW-Syllabus.pdf
Beltron Programmer IGNOU-MCA-NEW-Syllabus.pdf
Sitamarhi Institute of Technology
 
To help you with BEE (Basic Electrical Engineering)
To help you with BEE (Basic Electrical Engineering)
Sitamarhi Institute of Technology
 
STET 2025 900+ Computer MCQs in English PDF (studynotes.online).pdf
STET 2025 900+ Computer MCQs in English PDF (studynotes.online).pdf
Sitamarhi Institute of Technology
 
ChatGPT Foundations rompts given for each topic in both personal and business...
ChatGPT Foundations rompts given for each topic in both personal and business...
Sitamarhi Institute of Technology
 
Smart Phone Film Making.filmmaking but feel limited by the constraints of exp...
Smart Phone Film Making.filmmaking but feel limited by the constraints of exp...
Sitamarhi Institute of Technology
 
MS Word tutorial provides basic and advanced concepts of Word.
MS Word tutorial provides basic and advanced concepts of Word.
Sitamarhi Institute of Technology
 
CORPORATE SOCIAL RESPONSIBILITY CSR) through a presentation by R.K. Sahoo
CORPORATE SOCIAL RESPONSIBILITY CSR) through a presentation by R.K. Sahoo
Sitamarhi Institute of Technology
 
Ad

Recently uploaded (20)

A Comprehensive Investigation into the Accuracy of Soft Computing Tools for D...
A Comprehensive Investigation into the Accuracy of Soft Computing Tools for D...
Journal of Soft Computing in Civil Engineering
 
22PCOAM16 _ML_Unit 3 Notes & Question bank
22PCOAM16 _ML_Unit 3 Notes & Question bank
Guru Nanak Technical Institutions
 
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
kippcam
 
How Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdf
Mina Anis
 
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Alexandra N. Martinez
 
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
dayananda54
 
Fundamentals of Digital Design_Class_12th April.pptx
Fundamentals of Digital Design_Class_12th April.pptx
drdebarshi1993
 
Blood bank management system project report.pdf
Blood bank management system project report.pdf
Kamal Acharya
 
Great power lithium iron phosphate cells
Great power lithium iron phosphate cells
salmankhan835951
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
OCS Group SG - HPHT Well Design and Operation - SN.pdf
OCS Group SG - HPHT Well Design and Operation - SN.pdf
Muanisa Waras
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Water demand - Types , variations and WDS
Water demand - Types , variations and WDS
dhanashree78
 
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
aniket862935
 
Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...
Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...
João Esperancinha
 
Pavement and its types, Application of rigid and Flexible Pavements
Pavement and its types, Application of rigid and Flexible Pavements
Sakthivel M
 
Présentation_gestion[1] [Autosaved].pptx
Présentation_gestion[1] [Autosaved].pptx
KHADIJAESSAKET
 
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Takumi Amitani
 
Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401
Unknown
 
Fundamentals of Digital Design_Class_21st May - Copy.pptx
Fundamentals of Digital Design_Class_21st May - Copy.pptx
drdebarshi1993
 
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
kippcam
 
How Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdf
Mina Anis
 
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Alexandra N. Martinez
 
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
dayananda54
 
Fundamentals of Digital Design_Class_12th April.pptx
Fundamentals of Digital Design_Class_12th April.pptx
drdebarshi1993
 
Blood bank management system project report.pdf
Blood bank management system project report.pdf
Kamal Acharya
 
Great power lithium iron phosphate cells
Great power lithium iron phosphate cells
salmankhan835951
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
OCS Group SG - HPHT Well Design and Operation - SN.pdf
OCS Group SG - HPHT Well Design and Operation - SN.pdf
Muanisa Waras
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Water demand - Types , variations and WDS
Water demand - Types , variations and WDS
dhanashree78
 
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
aniket862935
 
Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...
Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...
João Esperancinha
 
Pavement and its types, Application of rigid and Flexible Pavements
Pavement and its types, Application of rigid and Flexible Pavements
Sakthivel M
 
Présentation_gestion[1] [Autosaved].pptx
Présentation_gestion[1] [Autosaved].pptx
KHADIJAESSAKET
 
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Takumi Amitani
 
Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401
Unknown
 
Fundamentals of Digital Design_Class_21st May - Copy.pptx
Fundamentals of Digital Design_Class_21st May - Copy.pptx
drdebarshi1993
 

PPS 1.1.INTRODUCTION TO COMPONENTS OF A COMPUTER SYSTEM (DISKS, MEMORY, PROCESSOR, WHERE A PROGRAM IS STORED AND EXECUTED, OPERATING SYSTEM

  • 1. PPS Unit – 1 Introduction To Programming 1.1 Introduction To Components Of A Computer System (Disks, Memory, Processor, Where A Program Is Stored And Executed Operating System, Compilers Etc). Disks: Generally, a disk is a a round plate on which data can be encoded. There are two basic types of disks: magnetic disks and optical disks. Magnetic Disks In magnetic disks, the data is encoded as microscopic magnetized needles on the disk's surface. You can record and erase data on a magnetic disk any number of times Magnetic disks come in a number of different forms:  Floppy disk: A typical 5¼-inch floppy disk can hold 360K or 1.2MB megabytes. 3½-inch floppies normally store 720K, 1.2MB or 1.44MB of data. Floppy disks or obsolete today.  Harddisk :Hard disks can store anywhere from 20MB to more than 1-TB (terabyte). Hard disks are also from 10 to 100 times faster than floppy disks.  Removablecartridge : Removable cartridges are hard disks encased in a metal or plastic cartridge, so you can remove them just like a floppy disk. Removable cartridges are fast, though usually not as fast as fixed hard disks. Memory: A memory is used to store data and instructions. Computer memory is the storage space in the computer, where data is to be processed and instructions required for processing are stored. The memory is divided into large number of small parts called cells. Each location or cell has a unique address, which varies from zero to memory size minus one. For example, if the computer has 64k words, then this memory unit has 64 * 1024 = 65536 memory locations. The address of these locations varies from 0 to 65535.
  • 2. Memory is primarily of three types −  Cache Memory  Primary Memory/Main Memory  Secondary Memory Cache Memory Cache memory is a high -speed semiconductor memory which can speed up the CPU. It acts as a buffer between the CPU and the main memory. It is used to hold those parts of data and program which are most frequently used by the CPU. The parts of data and programs are transferred from the disk to cache memory by the operating system, from where the CPU can access them. Advantages The advantages of cache memory are as follows −  Cache memory is faster than main memory.  It consumes less access time as compared to main memory.  It stores the program that can be executed within a short period of time.  It stores data for temporary use. Disadvantages The disadvantages of cache memory are as follows −  Cache memory has limited capacity.  It is too expensive. Primary Memory (Main Memory) Primary memory holds only those data and instructions on which the computer is currently working. It has a limited capacity and data is lost when power is switched off. It is generally made up of semiconductor device. These memories are not as fast as registers. The data and instruction required to be processed resides in the main memory. It is divided into two subcategories RAM and ROM. Characteristics of Main Memory  These are semiconductor memories.
  • 3.  It is known as the main memory.  Usually volatile memory.  Data is lost in case power is switched off.  It is the working memory of the computer.  Faster than secondary memories.  A computer cannot run without the primary memory. Secondary Memory This type of memory is also known as external memory or non-volatile. It is slower than the main memory. These are used for storing data/information permanently. CPU directly does not access these memories, instead they are accessed via input-output routines. The contents of secondary memories are first transferred to the main memory, and then the CPU can access it. For example, disk, CD-ROM, DVD, etc. Characteristics of Secondary Memory  These are magnetic and optical memories.  It is known as the backup memory.  It is a non-volatile memory.  Data is permanently stored even if power is switched off.  It is used for storage of data in a computer.  Computer may run without the secondary memory.  Slower than primary memories. Processor: A processor (CPU) is the logic circuitry that responds to and processes the basic instructions that drive a computer. The CPU is the main integrated circuitry (IC) chip in a computer, as it is responsible for interpreting most of computers commands. CPUs will perform most basic arithmetic, logic, and I/O operations, as well as allocate commands for other chips and components running in a computer. The basic elements of a processor include:  The arithmetic logic unit (ALU), which carries out arithmetic and logic operations on the operands in instructions.
  • 4.  The floating -point unit (FPU), also known as a math coprocessor or numeric coprocessor, a specialized co-processor that manipulates numbers more quickly than the basic microprocessor circuitry can.  Registers, which hold instructions and other data. Registers supply operands to the ALU and store the results of operations.  L1 and L2 cache memory. Their inclusion in the CPU saves time compared to having to get data from random access memory (RAM). CPU Operations The four primary functions of a processor are fetch, decode, execute and write back. Fetch- is the operation which receives instructions from program memory from a systems RAM. Decode- is where the instruction is converted to understand which other parts of the CPU are needed to continue the operation. This is performed by the instruction decoder Execute- is where the operation is performed. Each part of the CPU that is needed is activated to carry out the instructions. Program stored and executed operating system: Whenever you save your program(anything) into a file (any kind of file, say ‘add.c’), it automatically gets stored in the secondary storage that is the hard disk. The Operating System’s kernel (kernel’s File management system) does it for you. When you run program, it is loaded into the main/primary memory of the computer called RAM (the entire program is transferred to the RAM, by a small program called the loader (which often comes with the compiler i.e. is a part of the compiler). The program instructions are executed in the ALU (Arithmetic-Logic Unit) of the CPU (in its registers like the Accumulator). In order to execute the instructions , the CPU fetches the values of the variables (say, int a =10; int b =20;) in the program from the RAM, and stores the results also in the RAM (int sum =30;), which is then sent to the output buffer stream (stdout) , which prints the results (30) on the computer console/terminal, the Windows kernel (kernel’s I/O management system) does the printing .
  • 5. Compilers: Compiler is a program that translates source code into object code. The compiler derives its name from the way it works, looking at the entire piece of source code and collecting and reorganizing the instructions. Thus, a compiler differs from an interpreter, which analyses and executes each line of source code in succession, without looking at the entire program. The advantage of interpreters is that they can execute a program immediately. Compilers require some time before an executable program emerges. However, programs produced by compilers run much faster than the same programs executed by an interpreter. Every high- level programming language comes with a compiler. In effect, the compiler is the because it defines which instructions are acceptable. Because compilers translate source code into object code, which is unique for each type of computer many compilers are available for the same language. 1.2 Idea Of Algorithm: Steps To Solve Logical And Numerical Problems An algorithm is the finite set of English statements which are designed to accomplish the specific task. Study of any algorithm is based on the following four criteria 1. Design of algorithm:This is the first step in the creation of an algorithm. Design of algorithm includes the problem statement which tell user about the area for which algorithm is required. After problem statement next important thing required is the information about available and required resources. The last thing required in design of algorithm phase is information about the expected output.
  • 6. 2. Validation of algorithm: Once an algorithm is designed , it is necessary to validate it for several possible input and make sure that algorithm is providing correct output for every input. This process is known as algorithm validation. The purpose of the validation is to assure us that this algorithm will work correctly independently of the issues concerning the programming language it will eventually be written in. 3. Analysis of algorithm: Analysis of algorithms is also called as performance analysis. This phase refers to the task of determining how much computing time and storage an algorithm requires. The efficiency is measured in best case, worst case and average case analysis. 4. Testing of algorithm:This phase is about to testing of a program which coded as per the algorithm. Testing of such program consists of two phases:  Debugging: It is the process of executing programs on sample data sets to determine whether faulty results occur or not and if occur, to correct them.  Profiling : Profiling or performance measurement is the process of executing a correct program on data sets and measuring the time and space it takes to compute the result Characteristics of an algorithm  Input: Algorithm must accept zero or more inputs.  Output: Algorithm must provide at least one quantity.  Definiteness: Algorithm must consist of clear and unambiguous instruction.  Finiteness: Algorithm must contain finite set of instruction and algorithm will terminates after a finite number of steps.  Effectiveness: Every instruction in algorithm must be very basic and effective. Uses of algorithm  Algorithm provide independent layout of the program.  It is easy to develop the program in any desired language with help of layout.
  • 7.  Algorithm representation is very easy to understand.  To design algorithm there is no need of expertise in programming language. 1.3 Representation Of Algorithm: Flowchart/Pseudo Code With Examples. From Algorithms To Programs There are three ways to represent an algorithm. Consider the following algorithm of addition of two numbers Step 1 : Start Step 2 :Read a number, say x and y Step 3 :Add x and y Step 4 :Display Addition Step 5 :Stop 1. Flowcharts: A flow chart is a diagrammatic / pictorial representation of an algorithm. It is the simplest way of representation of algorithm. Initially an algorithm is represented in the form of flowchart and then flowchart is given to programmer to express it in some programming language. Logical error detection is very easy in flowchart as it shows the flow of operations in diagrammatic form. Once flowchart is ready it is very easy to write a program in terms of statements of a programming language. Following are the symbols used in designing the flowcharts. 2. Pseudo code: Pseudo code is the combination of English statements with programming methodology. In pseudo code, there is no restriction of following the syntax of the programming language. Pseudo codes cannot be compiled. It is just a previous step of developing a code for given algorithm. 3. Program: In this way of representation, complete algorithm is represented using some programming language by following the complete syntax of programming language. Sr. No. Name of Symbol Symbol Meaning / Purpose
  • 8. 1. Terminal To indicate START / STOP. Usually it is the first symbol and last symbol used in program logic. 2. Input / Output Statement To indicate input / output of Data 3. Processing Statement To indicate the processing of instructions. 4. Decision Box To indicate decision making and a branch to one or more alternatives. 5. Flow Lines To indicate the direction of flow of information. 6. Connector It is used when flowchart becomes long and need to be continued. Shows the continuity of the algorithm on the next page. 1.4 Source Code Source code is the list of human-readable instructions that a programmer writes—often in a word processing program—when he is developing a program. The source code is run through to turn it in compiler to machine code called as object code. 1.5 Variables (With Data Types) Variables And Memory Locations Variables are the names you give to computer memory locations which are used to store values in a computer program. Here are the following three simple steps −  Create variables with appropriate names.  Store your values in those two variables.  Retrieve and use the stored values from the variables.
  • 9. When creating a variable, we need to declare the data type it contains. Programming languages define data types differently. For example, almost all languages differentiate between ‘integers’ (or whole numbers, eg 12), ‘non-integers’ (numbers with decimals, eg 0.24), and ‘characters’ (letters of the alphabet or words).  char – a single 16-bit Unicode character, such as a letter, decimal or punctuation symbol.  boolean – can have only two possible values: true (1) or false (0). This data type is useful in conditional statements.  byte - has a minimum value of -128 and a maximum value of 127 (inclusive).  short– has a minimum value of -32,768 and a maximum value of 32,767  int: – has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647 (inclusive).  long – has a minimum value of -9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807 (inclusive).  float – a floating point number with 32-bits of precision  double – this is a double precision floating point number. 1.6 Type Casting/Type Conversion Type casting refers to changing variable of one data type into another. The compiler will automatically change one type of data into another. For instance, if you assign an integer value to a floating-point variable, the compiler will convert the int to a float. Casting allows you to make this type conversion explicit, or to force it when it would not normally happen. Type conversion in c can be classified into the following two types: 1. Implicit Type Conversion
  • 10. When the type conversion is performed automatically by the compiler without programmers intervention, such type of conversion is known as implicit type conversion or type promotion. int x; for(x=97; x<=122; x++) { printf("%c", x); /*Implicit casting from int to char thanks to %c*/ } 2. Explicit Type Conversion The type conversion performed by the programmer by posing the data type of the expression of specific type is known as explicit type conversion. The explicit type conversion is also known as type casting. Type casting in c is done in the following form: (data_type)expression; where, data_type is any valid c data type, and expression may be constant, variable or expression. For example, int x; for(x=97; x<=122; x++) { printf("%c", (char)x); /*Explicit casting from int to char*/ } The following rules need to be followed while converting the expression from one type to another to avoid the loss of information:  All integer types to be converted to float.  All float types to be converted to double.
  • 11.  All character types to be converted to integer. Example Consider the following code: int x=7, y=5 ; float z; z=x/y; /*Here the value of z is 1*/ If we want to get the exact value of 7/5 then we need explicit casting from int to float: int x=7, y=5; float z; z = (float)x/(float)y; /*Here the value of z is 1.4*/ 1.7 Run Time Environment (Static, Dynamic Location) Stands for "Runtime Environment." As soon as a software program is executed, it is in a run time state. In this state, the program can send instructions to the computer's processor and access the computer's memory and other system resources. When software developers write programs, they need to test them in the runtime environment. Therefore, software development programs often include an RTE component that allows the programmer to test the program while it is running. This allows the program to be run in an environment where the programmer can track the instructions being processed by the program and debug any errors that may arise. If the program crashes, the RTE software keeps running and may provide important information about why the program crashed. 1.8 Storage Classes (Auto, Register, Static, Extern) A storage class is used to describe the following things:  The variable scope.  The location where the variable will be stored.
  • 12.  The initialized value of a variable.  A lifetime of a variable. 1.9 Syntax And Logical Errors In Compilation A syntax error is an error in the source code of a program. Since computer programs must follow strict syntax to compile correctly, any aspects of the code that do not conform to the syntax of the programming language will produce a syntax error. • Spelling mistakes • Missing out quotes • Missing out brackets • Using upper case characters in key words e.g. IF instead of if • Missing out a colon or semicolon at end of a statement • Using tokens in the wrong order A logic error (or logical error) is a ‘bug’ or mistake in a program’s source code that results in incorrect or unexpected behaviour. It is a type of runtime error that may simply produce the wrong output or may cause a program to crash while running. 1.10 Object and Executable Code
  • 13.  Source code is the C program that you write in your editor and save with a ‘ .C ‘ extension which is un-compiled when written for the first time or whenever a change is made in it and saved. Object code is the output of a compiler after it processes the source code. The object code is usually a machine code, also called a machine language, which can be understood directly by a specific type of CPU. However, some compilers are designed to convert source code into an assembly language or some other another programming language. An assembly language is a human-readable notation using the mnemonics in the ISA of that particular CPU. Executable (also called the Binary) is the output of a linker after it processes the object code. A machine code file can be immediately executable, runnable as a program , or it might require linking with other object code files for example libraries to produce a complete executable program.