Unit - 1 Introduction
Unit - 1 Introduction
Unit - I
Introduction to Computer, Algorithm and Flowchart:
1.1 The Turing Machine architecture, The Von Neumann architecture,
Number system.
• An electronic device that accepts data as input, and transforms it under the influence of a set of
special instructions called Programs, to produce the desired output (referred to as Information).
• A computer has an internal memory, which stores data & instructions temporarily awaiting
processing, and even holds the intermediate result .
Program and Data:-
Program:
• A computer Program is a set of related instructions written in the language of the computer & is
used to make the computer perform a specific task.
Data :
• Data is a collection of raw facts, figures or instructions that do not have much meaning to the user.
• Data may be in form of numbers, alphabets/letters or symbols, and can be processed to produce
information.
The Turing Machine Architecture :-
• Turing Machine was invented by Alan Turing in 1936.
• A Turing machine consists of a tape of infinite length on which read and writes
operation can be performed.
• The tape consists of infinite cells on which each cell either contains input symbol
or a special symbol called blank.
• Turing Machine also consists of a head pointer which points to cell currently
being read and it can move in both directions.
The Turing Machine Architecture :
The Turing Machine Architecture :-
• A Turing machine is a general example of a central processing unit (CPU) that controls all data
manipulation done by a computer, with the canonical machine using sequential memory to
store data.
• Fixed Program Computers – Their function is very specific and they couldn’t be
re-programmed, e.g. Calculators.
• In this stored-program concept, programs and data are stored in a separate storage
unit called memories and are treated the same.
• This novel idea meant that a computer built with this architecture would be much
easier to reprogram.
The Von Neumann Architecture :-
It is also known as ISA (Instruction set architecture) computer and is having three
basic units:
• Control Unit:- A control unit (CU) handles all processor control signals. It
directs all input and output flow, fetches code for instructions, and controls how
data moves around the system.
Input/output Devices –
• Program or data is read into main memory from the input device or secondary
storage under the control of CPU input instruction.
• Data Bus: It carries data among the memory unit, the I/O devices, and the
processor.
• Address Bus: It carries the address of data (not the actual data) between memory
and processor.
• Control Bus: It carries control commands from the CPU (and status signals from
other devices) in order to control and coordinate all the activities within the
computer.
Number Systems :-
Based on the base value and the number of allowed digits, number systems are of
many types. The four common types of Number System are:
10000 + 0 + 200 + 80 + 5
10285
Number Systems :-
2. Binary Number System: -
• Number System with base value 2 is termed as Binary number system. It uses 2 digits i.e. 0 and 1
for the creation of numbers.
• The numbers formed using these two digits are termed as Binary Numbers.
• Binary number system is very useful in electronic devices and computer systems because it can
be easily performed using just two states ON and OFF i.e. 0 and 1.
• Decimal Numbers 0-9 are represented in binary as: 0, 1, 10, 11, 100, 101, 110, 111, 1000, and
1001
Examples:
• 14 can be written as 1110
• 19 can be written as 10011
• 50 can be written as 110010
Number Systems :-
• Octal Numbers can be converted to Decimal value by multiplying each digit with the
place value and then adding the result.
• Here the place values are 80, 81, and 82. Octal Numbers are useful for the representation of
UTF8 Numbers.
Example:
•(135)10 can be written as (207)8
• Digits from 0-9 are taken like the digits in the decimal number system but the digits from 10-15
are represented as A-F i.e. 10 is represented as A, 11 as B, 12 as C, 13 as D, 14 as E, and 15 as F.
Examples:
•(255)10 can be written as (FF)16
•An operating system is a large and complex system that can only be created by partitioning into
small parts.
•These pieces should be a well-defined part of the system, carefully defining inputs, outputs, and
functions.
•Although Windows, Mac, UNIX, Linux, and other OS do not have the same structure, most
operating systems share similar OS system components, such as file, memory, process, I/O device
management.
Components of Operating System :-
• Operating system components help you get the correct computing by detecting
CPU and memory hardware errors.
Components of Operating System :-
Process Management
The process management component is a procedure for managing many processes running
simultaneously on the operating system.
Every running software application program has one or more processes associated with them.
Process management keeps processes running efficiently.
It also uses memory allocated to them and shutting them down when needed.
The execution of a process must be sequential so, at least one instruction should be executed on
behalf of the process.
Components of Operating System :-
Process Management
• A file is a set of related information defined by its creator. It commonly represents programs (both
source and object forms) and data. Data files can be alphabetic, numeric, or alphanumeric.
•Main memory is a large array of storage or bytes, which has an address. The memory management
process is conducted by using a sequence of reads or writes of specific memory addresses.
•It should be mapped to absolute addresses and loaded inside the memory to execute a program.
•The selection of a memory management method depends on several factors. (that is the hardware
support and the algorithm).
•Main memory offers fast storage that can be accessed directly by the CPU.
Components of Operating System :-
• Secondary-Storage Management:-
• Main memory of the computer is very small to store all data and programs permanently. So the
computer system offers secondary storage to back up the main memory.
o Disk scheduling
Components of Operating System :-
I/O Device Management :-
Device management in an operating system controls the Input/output devices like disk,
microphone, keyboard, printer, magnetic tape, USB ports, camcorder, scanner, other accessories,
and supporting units.
• One of the important use of an operating system that helps to hide the variations
of specific hardware devices from the user.
•The various processes in an operating system need to be secured from other activities.
•Therefore, various mechanisms can ensure those processes that want to operate files, memory CPU, and other
hardware resources should have proper authorization from the operating system.
•Security refers to a mechanism for controlling the access of programs, processes, or users to the resources
defined by computer controls to be imposed, together with some means of enforcement.
Components of Operating System :-
Command Interpreter System :-
• The command interpreter is the primary interface between the user and the rest of
the system.
Components of Operating System :-
•A program that reads and interprets control statements is automatically executed when a new job is
started in a batch system or a user logs in to a time-shared system.
•Its function is quite simple, get the next command statement, and execute it.
•The command statements deal with process management, I/O handling, secondary storage
management, main memory management, file system access, protection, and networking.
Types of Software :-
• Systems Software is Programs that coordinate the activities and functions of the hardware and
various other programs.
• Application Software is Programs that help users solve particular computing problems.
Operating Systems ß Control the computer hardware and act as an interface with
applications programs.
Types of Software :-
System Software:-
• System software is computer software designed to operate the computer hardware to provide
basic functionality and to provide a platform for running application software.
• Refers to the operating system and all utility programs that manage computer resources at a low
level.
Function of System Software (Operating System) :-
• Allows end users to accomplish one or more specific (non-computer related) tasks.
• Word processor
• Spreadsheets
• Presentation Software
• Graphic Editor
• Web Browser
Types of Application Software
• SEQUENCE
• SELECTION
• ITERATION
Basic constructs of Algorithm and flowchart
Sequence :-
• Sequence logic is used for performing instructions one after another in sequence.
• Each step is followed in a specific sequence, hence the name “Sequence” can be
thought of as “do this, then do this, then do this”
Sequence :-
Selection (Decision):-
• Selection logic, also known as decision logic, is used for making decisions. Selection
logic is depicted as either an IF…THEN…ELSE or IF…..THEN structure.
• Selection can be thought of as “if something is true, take this action, otherwise take
that action”.
Iteration ( Loop/ Repetition):-
• Iteration logic is used when one or more instructions may be executed several times depending on
some condition.
Programming Errors in C
• Errors are the problems or the faults that occur in the program, which makes the
behavior of the program abnormal.
• Programming errors are also known as the bugs or faults, and the process of
removing these bugs is known as debugging.
• These errors are detected either during the time of compilation or execution.
Compilation process: Syntax and semantic errors, ASCII.
Programming Errors in C
• Syntax error
• Run-time error
• Linker error
• Logical error
• Semantic error
Compilation process: Syntax and semantic errors, ASCII.
Syntax error
• Syntax errors are also known as the compilation errors as they occurred at the
compilation time, or we can say that the syntax errors are thrown by the compilers.
• These errors are mainly occurred due to the mistakes while typing or do not follow
the syntax of the specified programming language.
• For example:-
• Semantic errors are the errors that occurred when the statements are not
understandable by the compiler.
The following can be the cases for the semantic error:
• Use of a un-initialized variable.
int i;
i=i+2;
• Type compatibility
int b = "javatpoint";
• Errors in expressions
int a, b, c;
a+b = c;
Compilation process: Syntax and semantic errors, ASCII.
Semantic error :-
ASCII code :-
• The full form of ASCII is the American Standard Code for information interchange.
• Each character or a special character is represented by some ASCII code, and each ascii code occupies
7 bits in memory.
• In C programming language, a character variable does not contain a character value itself rather the
ascii value of the character variable.
• The ascii value represents the character variable in numbers, and each character variable is assigned
with some number range from 0 to 127.
• In the above example, we assign 'A' to the character variable whose ascii value is 65, so 65 will be
stored in the character variable rather than 'A'.
ASCII code :-
ASCII code :-