C - Notes Unit-1
C - Notes Unit-1
Unit-1
Computer:
• It is an electronic device which takes input (Data), processes it and produces the output (Information).
Digital Computer:
A digital computer is a digital system that performs various computational tasks. The word digital implies
the info in computer is shown by variables that take a limited no. of discrete values. Then these values are processed
internally by components and discrete states are maintained.
Ist electronic digital computer developed in-1940. It was used mainly for numerical computations. In this case
the discrete elements are digits. So from this place we got the term- “Digital Computer.”
These machines (m/c) cooperate efficiently if only ‘2’ states are used.
Bit: Digital computers use the binary no. system, which has two digits: 0, 1.
A binary digit ≡ ‘bit’.
So information is represented in digital computers in group of bits.
By this group of bits we can not only represent binary nos. but also other discrete symbols (decimal
digits/letter/alphabet) can be shown with the help of many coding techniques. Further more development of symbols
& sets of Instructions (program) are also possible for doing many computations with the proper arrangement of bits.
(Coding methods)
Sarvesh Kr. Soni (Asst. Prof., Dept. of IT) 1
Computer System
Software Hardware
(instruction, data, Application) (Electronic components, electromech. Devices)
Digital Computer
A computer is an electronic machine like any other machine which takes inputs (raw data) and performs some
processing giving out processed data (information).
1. Input: This is the process of entering data and programs in to the computer system. Therefore, the input unit takes
data from us to the computer in an organized manner for processing.
2. Storage: The process of saving data and instructions permanently is known as storage. Data has to be fed into the
system before the actual processing starts. It is because the processing speed of Central Processing Unit (CPU) is so
fast that the data has to be provided to CPU with the same speed. Therefore the data is first stored in the storage unit
for faster access and processing. This storage unit or the primary storage of the computer system is designed to do
the above functionality. It provides space for storing data and instructions.
3. Processing: The task of performing operations like arithmetic and logical operations is called processing. The
Central Processing Unit (CPU) takes data and instructions from the storage unit and makes all sorts of calculations
based on the instructions given and the type of data provided. It is then sent back to the storage unit.
5. Control: The manner how instructions are executed and the above operations are performed. Controlling of all
operations like input, processing and output are performed by control unit. It takes care of step by step processing of
all operations inside the computer.
FUNCTIONAL UNITS
In order to carry out the operations mentioned in the previous section the computer allocates the task between its
various functional units. The computer system is divided into three separate units for its operation. They are
• Arithmetical Logical Unit (ALU): After you enter data through the input device it is stored in the primary
storage unit. The actual processing of the data and instruction are performed by Arithmetic Logical Unit. The
major operations performed by the ALU are addition, subtraction, multiplication, division, logic and
comparison. Data is transferred to ALU from storage unit when required. After processing the output is
returned back to storage unit for further processing or getting stored.
• Control Unit (CU) The next component of computer is the Control Unit, which acts like the supervisor seeing
that things are done in proper fashion. Control Unit is responsible for coordinating various operations using
time signal. The control unit determines the sequence in which computer programs and instructions are
executed. Things like processing of programs stored in the main memory, interpretation of the instructions
and issuing of signals for other units of the computer to execute them. It also acts as a switch board operator
when several users access the computer simultaneously. Thereby it coordinates the activities of computer’s
peripheral equipment as they perform the input and output.
Central Processing Unit (CPU) The ALU and the CU of a computer system are jointly known as the central
processing unit. You may call CPU as the brain of any computer system.
Computer H/w : It can be divided into 3 major parts
1. CPU
2. Memory (RAM)
3. I/O Processor
CPU has →
o Arithmetical & logical unit for data manipulation.
o No. of registers for data-storage
o Control circuits to fetch & execute Instructions.
MEMORY UNITS:- The memory of C.P.U. is register which is very small and very fast and also costly. Hence it
needed memory for storing information. Generally two type of memory uses in computer systems.
1. PRIMARY MEMORY (MAIN MEMORY):- Main memory is directly access by C.P.U. RAM (Random
Access Memory made of semiconductor) are used as main memory. It is called Random because C.P.U. can
access any location of memory any time. Its access time 10 nano second (n.s.).
Other semiconductor memory is ROM (Read Only Memory. ROM is permanents memory, difference can
be understands as bellow.)
STATIC RAM:- The static RAM retain information as long power supply is on. Static RAM made of D flip –
flops without use of capacitor. There is no need to refresh it. It is faster and costly than D-RAM.
DYNAMIC RAM:- Dynamic RAM are made of transistors and capacitor. Since capacitor has leakage property
hence it needed charge at random time (for few second).That’s why it is called dynamic RAM. Slower but higher
capacity than DRAM.
Any RAM can be faster by using Cache memory between C.P.U. register and main memory. Another RAM is
EDO RAM → Extended data output RAM
SDRAM → Synchronous DRAM (Same clock
SGRAM → Synchronous Graphics RAM rate a C.P.U )
DDRSDRAM → Double Data Rate DRAM (Transfer data from both edges of clocks )
Software
Program: A sequence of instructions for the computer is called a program. The data that are manipulated by
the program create the database.
1. System software-It is the software used to manage and control the hardware components and which allow
interaction between the hardware and the other types of software. The most obvious type of system software
is operating system and device drivers.
Utility software-It is software such as anti-virus software, firewalls, disk defragmenters and so on.
which helps to maintain and protect the computer system but does not directly interface with the hardware.
2. Applications software (also known as 'apps') are designed to allow the user of the system to complete a
specific task(application). They include programs such as web browsers, MS office, games, media players
and so on.
Registers are embedded inside the CPU. They have very less capacity but
fastest speed. CPU uses some specific registers like PC (program counter), IR
Fastest Register
(instruction register), MAR (memory address register), MDR (memory data
register) and some GPR (general purpose registers),Ax(Accumulator register).
Cache memory is memory actually embedded inside the CPU. Cache memory
is very fast, typically taking only once cycle to access, but since it is
Faster Cache embedded directly into the CPU there is a limit to how big it can be. In fact,
there are several sub-levels of cache memory (termed L1, L2, L3) all with
slightly increasing speeds.
All instructions and storage addresses for the processor must come from
Slower RAM. Although RAM is very fast, there is still some significant time taken
than RAM for the CPU to access it (this time is latency). RAM is stored in separate,
Cache dedicated chips attached to the motherboard, meaning it is much larger than
cache memory.
We are all familiar with software arriving on a floppy disk or CDROM, and
saving our files to the hard disk. We are also familiar with the long time a
Slowest Disk program can take to load from the hard disk -- having physical mechanisms
such as spinning disks and moving heads means disks are the slowest form of
storage. But they are also by far the largest form of storage.
FLOPPY DISC:- Floppy disc have single disc and R/W heads in floppy
Disc drive. The sized floppy disc is 1.44MB.Two type of floppy disc depend on size.
OPTICAL DEVICES: Optical disc is same as magnetic disc but it does not contain magnetic foil at its surface.
The optical disc made by other type of materials. A disc surface PIT and LAND made by laser beam. The PIT
denote ‘1’ and LAND denote ‘0’ .When laser beam exposing on surface of disc by R/W head. The reflected beam
suffer different distance from PIT and LAND as shown in figure .By this property head can differentiate between
PIT (1) and LAND (0).
MEGNETIC DISC:- Magnetic disc include floppy disc and hard disc. Working principle of both is same. Data
stores on disc surface. Its surfaces divided into co centric track and each track divided into sectors. The disc is
mounted on a rotary drive (D.C. Motor) to rotate disc. After read data R/W head remains stationary, while disc
rotate continuously. All
tracks contain same number of bytes. Hence track which is nearer to centre is denser (complex) than outer tracks. A
disc may other structure that a sector contains different no. of tracks.
Hard disc is combination of more disc in co centric frame as shown below. Read/write Head. The data can be
access only with read/write heads. All disc are rotating continuously and head move forward and backward
direction as required. Size of hard disc is varying in few GB now in TB.
CACHE MEMORY: - Cache memory placed between C.P.U. and main memory. It consists of static RAM. Its
access time is about 10 n.s. Cache memory help to provide data to C.P.U. as needed. Since Ram can not provide as
speed as C.P.U. need, so Cache are use to remove this difficulty.
SECONDARY MEMORY: - Secondary memory is also known as permanent strong. It stores files (Text, Audio,
Video etc) and other format of data. The stored file transfer from secondary memory to Primary memory when
needed by computer for execution of any program because any file can not executed in secondary memory it can be
executed any Primary memory (RAM).Two type of Secondary memory used today
o Magnetic memory
o Optical memory
MAGNETIC MEMORY: - Magnetic memory is not volatile it is used for backup memory. Digital data 0 and 1
store on magnetic coating film. The binary digit depends on direction of magnetization of very small area of
magnetic film. There are two technique used for storing data.
o Longitudinal recording
o Vertical recording
Operating System
An O.S. acts as an intermediary between the user of a computer S/W & the computer H/w.
“The purpose of an O.S. is to provide an event. in which a user can execute programs in a convenient &
efficient manner.”
O.S. is a S/w which controls or operates the H/w of computer.
H/w of computer : CPU, memory, I/O devices Etc. (touch & feel)
S/w of computer : Packages for different applications.
: Compliers of different Languages
: Others, Information/data (e-mail, …)
So O.S. is just like a government, it does nothing (important) useful functions by itself. It only provides an environment
within which other programs can do useful work.
1. Batch OS :The users of batch operating system do not interact with the computer directly. Each user prepares
his job on an off-line device like punch cards and submits it to the computer operator. Main problems are -
Lack of interaction between the user and job, CPU is often idle.
2. Real-time OS: A real-time operating system is a multitasking operating system that aims at executing real-
time applications. Real-time operating systems often use specialized scheduling algorithms so that we can
perform multiple tasks simultaneously. The main objective of real-time operating systems is their quick and
predictable response to events. They have an event-driven or time-sharing design. Ex- VxWorks, MARS,
RTLinux
3. Multi-user OS: A multi-user operating system allows multiple users to access a computer system at the same
time. Time-sharing systems and Internet servers can be classified as multi-user systems. Single-user operating
systems have only one user but may allow multiple programs to run at the same time.Ex-UNIX,Main-
Frame,Supercomputer.
4. Distributed OS: A distributed operating system manages a group of independent computers and makes them
appear to be a single computer. The development of networked computers that could be linked and
communicate with each other gave rise to distributed computing. Distributed computations are carried out on
more than one machine. When computers in a group work in cooperation, they make a distributed system.Ex-
NFS-Andrew,Amoeba
Programming Lang.
FLOWCHARTS
stop
Algorithm:
Step 1 : start
Setp 2 : read temperature in centrigrade Start
Step 3 : caluculate Fahrenheit = 32 + (centigrade * (1.8));
Step 4 : display centigrade and Fahrenheit
Step 5 : stop
Read cent
Flow chart
Fah = 32+(cent*1,8)
End
Algorithm:
1.Start
2. Read the value of radius r of Circle
3. Give Pi = 3.14
4. Calculate area of Circle A= Pi x r x r
5. Calculate Circumference of circle
C= 2 X Pi X r
5. Print area =A and Circumference =C
6.End.
iv) Write a program to find greatest among three numbers Take a,b,c
ALGORITHM:
Step1:start If
Step2:input a,b,c (a>b)&&(a
>c)
Step3:if(a>b) &&(a>c) Display a
Step4:display a is grater
Step 5:else
Step6:if(b>c) If (b>c)
Algorithm: start
Step1: start
Step2: read n Read n
Step3: i=0,sum=0
Step4: perform from step 5 to step 6 until i<=n
Step5: i++
i=0;sum=0
Step6:sum+=i;
Step7: write sum
Step8: stop
While(i<=n)
Flow chart:
I=i+1
Sum+=i
Write sum
stop
Stop
Structured programming
Structured programming, sometimes known as modular programming.
It is a subset of procedural programming that enforces a logical structure on the program being written to make it
more efficient and easier to understand and modify.
It is A technique for organizing and coding computer programs in which a hierarchy of modules is used, each having
a single entry and a single exit point.
In Struct.Prog., control is passed downward through the structure without unconditional branches to higher levels of
the structure.
A defined function or set of similar functions is coded in a separate module or sub module, which means that the
code can be loaded in to memory more efficiently and that modules can be reused in other programs.
After a module has been tested individually, it is then integrated with other modules into the overall program structure.