0% found this document useful (0 votes)
10 views78 pages

CFP - Unit 1

The document provides an overview of computer fundamentals, covering basic computer organization, memory hierarchy, and the relationship between hardware and software. It introduces program planning tools like algorithms and flowcharts, emphasizing their importance in writing correct programs. Additionally, it discusses the software development process, including coding, testing, and the roles of various tools such as editors, compilers, and linkers.

Uploaded by

NAMDEO
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views78 pages

CFP - Unit 1

The document provides an overview of computer fundamentals, covering basic computer organization, memory hierarchy, and the relationship between hardware and software. It introduces program planning tools like algorithms and flowcharts, emphasizing their importance in writing correct programs. Additionally, it discusses the software development process, including coding, testing, and the roles of various tools such as editors, compilers, and linkers.

Uploaded by

NAMDEO
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 78

COMPUTER FUNDAMENTALS AND PROGRAMMING

UNIT 1

INTRODUCTION TO COMPUTER FUNDAMENTALS

By. Prof.N. D. Kapale


Course Contents
No.
Unit- of
Introduction to Computer Fundamentals COs
I Ho
urs
Basic Computer Organization: Block diagram
of Computer System, Functional Units: CPU,
ALU, Memory, I/O Devices, Hardware and
Software
Introduction to Program Planning Tools:
Algorithm, Flowcharts 06 CO1
Introduction to System Software: IDE,
Assembler, Compiler, Linker, Loader,
Debugger: breakpoints, syntax and logical
errors
Computer
 The Word Computer comes from
the word “Compute”, which
means to “To Calculate”
 A Computer is an electronic

device that can perform


arithmetic operations at high
speed.
 A Computer is also called a Data

Processor because it can store,


5 Basic operations of
computer
1. Inputting: The process of entering
data and instructions into the computer
system.
2. Storing: Saving data and instructions
to make them readily available for
initial or additional processing
whenever required.
3. Processing: Performing arithmetic
operations (add, subtract, multiply,
divide, etc.) or logical operations
5 Basic operations of
computer
4. Outputting: The process of producing
useful information or results for the user
such as a printed report or visual display.
5. Controlling: Directing the manner and
sequence in which all of the above
operations are performed
CP
U
Memory Hierarchy
Main Memory:
1. Every computer has a temporary storage built into
the computer hardware.
2. It stores instructions and data of a program mainly
when the program is being executed by the CPU.
3. This temporary storage is known as main memory,
primary storage, or simply memory.
4. Physically, it consists of some chips either on the
motherboard or on a small circuit board attached
to the motherboard of a computer.
5. It has random access property.
6. It is volatile.
Memory Capacity
 Memory capacity of a computer is equal to the number
of bytes that can be stored in its primary storage.
 Its units are:
 Kilobytes (KB):1024 (210) bytes
 Megabytes (MB):1,048,576 (220) bytes
 Gigabytes (GB):1,073,741824 (230) bytes
Random Access Memory
(RAM)
 Primary storage of a computer is often referred
to as RAM because of its random access
capability.
 RAM chips are volatile memory.
 A computer’s motherboard is designed in a
manner that the memory capacity can be
enhanced by adding more memory chips.
 The additional RAM chips, which plug into
special sockets on the motherboard, are known
as single-in-line memory modules (SIMMs).
 DDR -Double Date Rate, SDD: Solid State
Device
Read Only Memory (ROM)
 ROM a non-volatile memory chip.
 Data stored in a ROM can only be read
and used –they cannot be changed.
 ROMs are mainly used to store programs
and data, which do not change and are
frequently used.
 For example, system boot program
BIOS (Basic Input Output System)
Cache Memory
 It is commonly used for minimizing
the memory-processor speed
mismatch(Latancy).
 It is an extremely fast, small memory

between CPU and main memory


whose access time is closer to the
processing speed of the CPU.
 It is used to temporarily store very

active data and


instructions(frequently used) during
Storage Evaluation Criteria
Input an output devices

 students should perform a survey and


enlist different input and output devices
Terminologies

 Hardware refers to the physical


devices of a computer system.
 Software refers to a collection of

programs.
 Program is a sequence of

instructions written in a language


that can be understood by a
computer.
 Software package is a group of
Relationship Between Hardware and
Software
 Both hardware and software are necessary for a
computer to do useful job. They are complementary
to each other.
 Same hardware can be loaded with different
software to make a computer system perform
different types of jobs.
 Except for upgrades, hardware is normally a one-
time expense, whereas software is a continuing
expense.
 Upgrades refer to renewing or changing components
like increasing the main memory, or hard disk
capacities, or adding speakers, modems, etc.
Types of Software
 Software can be divided into two
major categories:
1. System software are designed to
control the operation and extend
the processing capability of a
computer system.
Examples of System Software are Operating
Systems, Programming Language Translators, Utility
Programs, and Communications Software
2. Application software are
designed to solve a specific
problem or to do a specific task
Examples of Application Software are Word
Purpose of Program
Planning
 To write a correct program, a programmer
must write each and every instruction in
the correct sequence.
 Logic (instruction sequence) of a program
can be very complex.
 Hence, programs must be planned before
they are written to ensure program
instructions are:
 Appropriate for the problem
 In the correct sequence
Algorithm
 Refers to the logic of a program and a step-by-step
description of how to arrive at the solution of a
given problem.
 In order to qualify as an algorithm, a sequence of
instructions must have following characteristics:
 Each and every instruction should be precise and
unambiguous.
 Each instruction should be such that it can be
performed in a finite time.
 One or more instructions should not be repeated
infinitely. This ensures that the algorithm will ultimately
terminate.
 After the algorithm terminates, the desired results must
Example 1: Problem
 There are 50 students in a class who
appeared in their final examination.
Their mark sheets have been given to
you.
 The division column of the mark sheet
contains the division (FIRST, SECOND,
THIRD or FAIL) obtained by the student.
 Write an algorithm to calculate and print
the total number of students who passed
in FIRST division.
Algorithm
 Step 1: Define & Initialize Total_First_Division and
Total_Marksheets_Checked to zero.
 Step 2: Take the mark sheet of the next student.
 Step 3: Check the division column of the mark
sheet to see if it is FIRST, if no, go to Step 5.
 Step 4: Add 1 to Total_First_Division.
 Step 5: Add 1 to Total_Marksheets_Checked.
 Step 6: check if Total_Marksheets_Checked = 50,
if no, go to Step 2.
 Step 7: Print Total_First_Division.
 Step 8: Stop.
Example 2: Problem
 There are 100 employees in an organization. The organization
wants to distribute annual bonus to the employees based on
their performance. The performance of the employees is
recorded in their annual appraisal forms.
 Every employee’s appraisal form contains his/her basic salary
and the grade for his/her performance during the year. The
grade is of three categories –‘A’ for outstanding performance,
‘B’ for good performance, and ‘C’ for average performance.
 It has been decided that the bonus of an employee will be
100% of the basic salary for outstanding performance, 70% of
the basic salary for good performance, 40% of the basic salary
for average performance, and zero for all other cases.
 Write an algorithm to calculate and print the total bonus
amount to be distributed by the organization
Algorithm
 Step 1: Initialize Total_Bonus and Total_Employees_Checked to
zero.
 Step 2: Initialize Bonus and Basic_Salary to zero.
 Step 3: Take the appraisal form of the next employee.
 Step 4: Read the employee’s Basic_Salary and Grade.
 Step 5: If Grade = A, then Bonus = Basic_Salary. Go to Step 8.
 Step 6: If Grade = B, then Bonus = Basic_Salary x 0.7. Go to
Step 8.
 Step 7: If Grade = C, then Bonus = Basic_Salary x 0.4.
 Step8: Add Bonus to Total_Bonus.
 Step 9: Add 1 to Total_Employees_Checked.
 Step 10: If Total_Employees_Checked < 100, then go to Step 2.
 Step 11: Print Total_Bonus.
 Step 12: Stop.
Representation of
Algorithms
 As programs
 As flowcharts
 As pseudo codes
 When an algorithm is represented in the form of a
programming language, it becomes a program.
 Thus, any program is an algorithm, although the
reverse is not true
Flowchart
 Flowchart is a pictorial representation of an
algorithm.
 Uses symbols (boxes of different shapes) that
have standardized meanings to denote different
types of instructions.
 Actual instructions are written within the boxes.
 Boxes are connected by solid lines having arrow
marks to indicate the exact sequence in which
the instructions are to be executed.
 Process of drawing a flowchart for an algorithm
is called flowcharting.
Basic Flowchart Symbols
Example
Flowchart example
 A student appears in an examination, which
consists of total 10 subjects, each subject having
maximum marks of 100.
 The roll number of the student, his/her name, and
the marks obtained by him/her in various subjects
are supplied as input data.
 Such a collection of related data items, is known
as a record.
 Draw a flowchart for the algorithm to calculate
the percentage marks obtained by the student in
this examination and then to print it along with
his/her roll number and name
Sample Flowchart (Example
4)
 50 students of a class appear in the
examination of Example 3.
 Draw a flowchart for the algorithm to
calculate and print the percentage
marks obtained by each student along
with his/her roll number and name.
Flowcharting Rules
 Be consistent in using names and variables in the
flowchart.
 Go from left to right and top to bottom in constructing
flowcharts.
 Keep the flowchart as simple as possible. Crossing of
flow lines should be avoided as far as practicable.
 If a new flowcharting page is needed, it is recommended
that the flowchart be broken at an input or output point.
 Properly labeled connectors should be used to link the
portions of the flowchart on different pages
Advantages of Flowchart
 Better Communication
 Proper program documentation

 Efficient coding

 Systematic debugging

 Systematic testing
Limitations of Flowchart
 Flowcharts are very time consuming
and laborious to draw (especially for
large complex programs).
 Redrawing a flowchart for incorporating

changes/ modifications is a tedious


task.
 There are no standards determining the

amount of detail that should be


included in a flowchart
Pseudocode
 A program planning tool where program logic is
written in an ordinary natural language using a
structure that resembles computer instructions.
 “Pseudo” means imitation or false and “Code”

refers to the instructions written in a


programming language. Hence, pseudocode is an
imitation of actual computer instructions.
 Because it emphasizes the design of the program,

pseudocode is also called Program Design


Language (PDL)
Logical System
Architecture
 Relationship among hardware, system
software, application software, and users
of a computer system
Various steps involved in software
development

1. Analyzing the problem at hand and


planning the program(s) to solve the
problem
2. Coding the program(s)
3. Testing, debugging, and documenting
the program(s)
4. Evaluating and maintaining the
program(s)
To carry out all these steps, following
tools are used :

 Editor
 Assembler
 Compilers
 Interpreters
 Linker
 Loader
 Debugger
Editor
 Software programs that enable the user to create
and edit text files.
 The term editor usually refers to source code
editors that include many special features for
writing and editing code.
 Features normally associated with text editors
are — moving the cursor, deleting, replacing,
pasting, finding, finding and replacing, saving
etc.
 Examples : Turbo C, atom, notepad++, etc.
Assembler
 Software that translates as assembly
language program into an equivalent
machine language program of a
computer
Compiler
 Translator program (software) that
translates a high-level language
program into its equivalent machine
language program
 Compiles a set of machine language
instructions for every program
instruction in a high-level language
Compiler
 Illustrating the requirement of a separate
compiler for each high-level language
supported by a computer.
Linker
 For a large software, storing all the lines of
program code in a single source file will be:
 Difficult to work with

 Difficult to deploy multiple programmers to

concurrently work towards its development


 Any change in the source program would

require the entire source program to be


recompiled
 Hence, a modular approach is generally adapted
to develop large software where the software
consists of multiple source program files.
 No need to write programs for some modules as
Linker
 Each source program file can be independently
modified and compiled to create a corresponding
object program file.
 Linker program (software) is used to properly
combine all the object program files (modules)
 Creates the final executable program (load
module)

 Exercise : What is loader and its role in


programming?
Interpreter
 It is a high-level language translator
 Takes one statement of a high-level
language program, translates it into machine
language instructions
 Immediately executes the resulting machine
language instructions
 Compiler simply translates the entire source
program into an object program and is not
involved in its execution
Do it yourself
 Find information and examples of
Intermediate language compilers and
Interpreters?
 Identify for following programming
languages whether will you use compiler
or interpreter 1. C 2. C++ 3. python 4.
java 5. SQL
 Illustrate assembly language and
machine language with suitable
examples? Identify editors available for
assembly language programming.
Operating System (OS)
 Definition and need for operating
system
 Definition : Operating System (OS) is an

Integrated set of programs that controls


the resources (the CPU, memory, I/O
devices, etc.) of a computer system
 Need
 Provides its users with an interface or

virtual machine that is more convenient


to use than the bare machine
 Two primary objectives of an OS

are:
Logical Architecture of Computer
System
 The operating system
layer hides the details of
the hardware from the
programmer and
provides the
programmer with
convenient interface for
using the system.
Parameters for Measuring System are

 Throughput: Amount of work that


the system is able to do per unit
time.
 Turnaround time: Interval from the

time of submission of a job to the


system for processing to the time of
completion of the job.
 Response time: Interval from the

time of submission of a job to the


system for processing to the time
Process Management
 A process (also called job) is a program
in execution
 Process management manages the
processes submitted to a system in a
manner to minimize idle time of
processors (CPUs, I/O processors, etc.) of
the system.
 Types of Process or jobs
 CPU bound: Mostly perform computations
with little I/O operations. Scientific and
engineering computations usually fall in
Types of Process
Management
1. Uni programming: Only one job is processed at a time and all
system resources are available exclusively for the job until its
completion.
2. Multiprogramming: Interleaved [means included] execution of
two or more different and independent programs by a computer.
3. Multitasking : Interleaved execution of multiple jobs (often
referred to as tasks of same user) in a single-user system.
4. Multithreading: Thread is basic unit of CPU utilization. Threads
share a CPU in the same way as processes do. All threads of a
process also share the same set of operating system resources.
 Do it Yourself Activity :
 Find details on : Multiprocessing - One more type of Process
management.
 Identify types of process management supported by these OS :
Windows 98, Windows7, Windows 10, Linux, Android, ios, Macos.
Memory management
 Memory is important resource of a computer
system that must be properly managed for the
overall system performance.
 Memory management module:
 Keeps track of parts of memory in use and parts
not in use.
 Allocates memory to processes as needed and
deallocates when no longer needed.
 Do it Yourself Activity :
 Find use of cache memory & virtual memory in
computer system.
 What are memory devices available in your mobile ?
File management
 A file is a collection of related information.
 Every file has a name, its data and attributes.
 File’s name uniquely identifies it in the system and is used by its
users to access it.
 File’s data is its contents
 File’s attributes contain information such as date & time of its
creation, date & time of last access, date & time of last update, its
current size, its protection features, etc.
 File management module of an operating system takes care of
file-related activities such as structuring, accessing, naming,
sharing, and protection of files.
 Do it Yourself Activity :
 Find meanings for following file
extensions : .bas .c .ftn .pas .exe .obj .bin .lib, .dat .csv .hlp .man .t
xt .doc .png .ppt .jpg .mpg .pdf .gif
Security
 Deals with protecting the various resources and
information of a computer system against destruction and
unauthorized access.
 External security: Deals with
 securing computer against external factors such as fires,
floods, earthquakes, stolen disks/tapes, etc. by maintaining
adequate backup
 using security guards
 allowing access to sensitive information to only trusted
employees/users, etc.
 Internal security: Deals with
 user authentication,
 access control,
 cryptography mechanisms
Command interpretation
 Two types of user interfaces supported
by various operating systems are:
 Command-line interface (CLI): User gives
instructions to the computer by typing the
commands
 Graphical User Interface (GUI): User gives
commands to the system by selecting icon
or menu item displayed on the screen with
the use of a point and draw device.
 Do it Yourself Activity :
 Enlist software as well as operating system
who uses either CLI or GUI or both types of
Do it yourself :
 Find examples of popular operating
systems.
 Compare Microsoft Windows and Linux
operating system.
 Operating system is system software or
application software ? Comment on it
carefully.
 Do you think is there any difference
between computer operating systems
and mobile phone operating systems ? If
yes, justify your answer.
What is an IDE ?
 “An IDE, or Integrated Development
Environment, enables programmers to
join the different aspects of writing a
computer program.”
 IDEs increase programmer productivity
by combining common activities of
writing software into a single application:
 Editing source code,
 Building executable,
 Debugging.
 Let us in brief about these usages of
IDE Usages
 Editing Source Code : Writing code is an important part of
programming. We start with a blank file, write a few lines of code,
and a program is born!
 IDEs facilitate this process with features like syntax highlighting and
autocomplete.
1. Syntax Highlighting : An IDE that knows the syntax of your
language can provide visual cues. Keywords, words that have
special meaning like class in Java, are highlighted with different
colors.
 Syntax highlighting makes code easier to read by visually
clarifying different elements of language syntax.
2. Autocomplete : When the IDE knows your programming language,
it can anticipate what you’re going to type next!
IDE Usages
 Building Executable
 Before programs run, the source code of program file must be
transformed into an executable or binaries by the compiler. Once
compiled, the program can be run from the terminal.
 This compilation process is necessary for every program, so why not
have the IDE do it for us? IDEs provide automated build processes
for languages, so the act of compiling and executing code is abstract
way.
 Debugging
 No programmer avoids writing bugs and programs with errors.
 When a program does not run correctly, IDEs provide debugging
tools that allow programmers to examine different variables and
inspect their code in a deliberate way.
 IDEs also provide hints while coding to prevent errors before
compilation.
IDE Examples
 Visual Studio : It is an open-source code editor developed
by Microsoft for Windows, Linux and Mac OS.
 This IDE is also customizable which lets programmers
change the theme, keyword shortcuts and preferences.
 Key Benefits: Support for Debugging, Syntax highlighting,
Intelligent Code completion, snippets and code refactoring,
EmbeddedGit Control, Completely portable, Easy
customization
 Programming Languages Supported: C, C++, C#, CSS,
Go, HTML, Java, JavaScript, Python, PHP, Typescript and
much more!
IDE Examples

Atom : Highly configurable
text editors which is free
for personal and commercial developments.
 Designed and developed by GitHub and has a very large community.
 A multitude of plugins are available for this editor which extends its
features and makes it more customizable.
 Supports OS X, Windows and Linux, and has a very simple interface to
work on.
 Key Benefits: Cross-platform support, Smart auto completion,
Package manager, Plugins support, Multiple panes , and so on.
 Programming Languages Supported: C/C++, CSS, HTML,
JavaScript, PHP, Python, Ruby and others.
 Download : https://atom.io/
IDE Examples
 Code:: Blocks
 It is a free, open-source IDE that was developed in C++
using wxWidgets as a GUI toolkit.
 Code::Blocks is an extensible and highly customizable IDE
that performs on all platforms including Linux, Mac and
Windows.
 Any function can be added to this IDE by installing or
coding a plugin.
 For e.g., functions of compiling and debugging are
available because of plugins.
 Code::Blocks support various pre-built plugins as well as
custom plugins.
IDE Examples Code:: Blocks contd

 Programmers can easily tweak the IDE accordingly


and can also easily navigate through the tab
interface.
 Initially, it was created for C++ but now you can
also run C programs.
 Key Benefits: Compatible with Linux, Mac, and
Windows , Smart Code Completion, Easy Navigation
Integrated intelligent Syntax highlighting, Full-
featured debugger, Rich Community
 Programming Languages Supported: C, C++,
Fortran
 Download : http://www.codeblocks.org/
Do it Yourself:

 Find few more IDEs used for C Programming.


Enlist them. Which IDE was the most
popular in last Year ?
 Download atom IDE and install it on your
computer. Do simple Hello World Program in
it and understand use of its features.
 Identify mobile phone based IDE for your C
programming and try anyone on your
mobile phone.
 Is there any difference have you identified
in Online Compilers and IDEs? Justify in your
Program Debugging
 Testing and Debugging of programs
 Program errors are known as Bugs and process of

detecting and correcting these errors is called


Debugging.
 Testing is the process of making sure that the

program performs the intended task.


 Debugging is the process of locating and

eliminating program errors.


Types of Program Errors
 Syntax and Logical Errors
Syntax errors
 Occurs when the rules or syntax of the programming

language are not followed. For example, incorrect


punctuation, incorrect word sequence, undefined terms, and
misuse of terms.
 Syntax errors are detected by a language processor.

Logic errors
 Occurs due to errors in planning a program’s logic.

 Such errors cause the program to produce incorrect output.

 These errors cannot be detected by a language processor.


Testing of a Program
 Testing procedure involves running program to
process input test data, and comparing obtained
results with correct results.
 Test data must test each logical function of the

program, and should include all types of possible


valid and invalid data.
 Program internally released for testing is known as

alpha version and the test conducted on it is called


alpha testing.
 Program released for additional testing to a

selected set of external users is beta version and


test conducted on it called is beta testing.
Debugging of a Program for Syntax Error

 Relatively easier to detect and correct syntax errors


than logic errors in a program.
 Language processors are designed to automatically

detect syntax errors.


 Single syntax error often causes multiple error

messages to be generated by the language


processor.
 Removal of the syntax error will result in the

removal of all associated error messages.


Debugging of a Program for Logical Error

 Logic errors are more difficult to detect than syntax errors


as computer does not produce any error message for such
errors.
 One or more of following methods are commonly used for
locating logic errors:
 Doing hand simulation of the program code.
 Putting print statements in the program code.
 Using a debugger (a software tool that assists a
programmer in following the program’s execution step-
by-step).
 Using memory dump (printout of the contents of main
memory and registers).
Difference between Testing and
Debugging
Do it Yourself:
 Go in Turbo C Editor and do hands on
the following under debugging with
suitable example: Single Step
Breakpoints, and Add Watch Variables and
 Observe :
1. What happened in single step breakpoint use
in debugging?
2. How to add watch variable and its use during
debugging of the program?
What is Debugger?
In general, debugger is utility that runs target
program in controlled environment where you can
control execution of program and see the state of
program when program is paused.
We can tell debugger when to pause a program by
setting breakpoints.
Once you set breakpoint, when you start program in debug mode, it will pause
execution when program reaches the line where breakpoint is set.
1. Continue – Resume program execution until next
breakpoint is reached
2. Step over – Execute program line by line but don’t
go inside function call
3. Step into – Execute program line by line stepping
into function
4. Step out – Resume program execution until current
function is finished
$ vim factorial.c
# include <stdio.h>

int main()
{
int i, num, j;
printf ("Enter the number: ");
scanf ("%d", &num );

for (i=1; i<num; i++)


j=j*i;
printf("The factorial of %d is %d\n",num,j);
}
THANK YOU

You might also like