C-Notes Module 1
C-Notes Module 1
C-Notes Module 1
RAM is the primary memory of the computer. It can be used every time of computer
process the instruction. It is an active memory of the system. It holds the data temporarily. It
works high speed than other memory. However we are using RAM.
Contains a large number of semiconductor cells each capable of storing one bit of
information
These cells are processed in group of fixed size called words containing „n‟ bits. The
main memory is organized such that the contents of one word can be stored or retrieved
in one basic operation.
For accessing data, a distinct address is associated with each word location.
Data and programs must be in the primary memory for execution.
PROCESSOR UNIT
The heart of the computer system is the Processor unit.
It consists of Arithmetic and Logic Unit and Control Unit.
Arithmetic and Logic Unit (ALU)
Most computer operations (Arithmetical and logical) are executed in ALU of the
processor.
For example: Suppose two numbers (operands) located in the main memory are to be
added. These operands are brought into arithmetic unit – actual addition is carried. The
result is then stored in the memory or retained in the processor itself for immediate use.
Note that all operands may not reside in the main memory. Processor contains a number
of high speed storage elements called Registers, which may be used for temporary
storage of frequently used operands. Each register can store one word of data.
Access times to registers are 5 to 10 times faster than access time to memory.
Control Unit
The operations of all the units are coordinated by the control unity (act as the nerve
centre that sends control signal to other units)
Timing signal that governs the I/O transfers are generated by the Control Unit.
Synchronization signals are also generated by the Control Unit
By selecting, interpreting and executing the program instructions the program instructions
the control unit is able to maintain order and direct the operation of the entire system
Storage Devices
Hard Disk, DVD, Pen Drive are the storage devices. It holds the data even switch off
the computer. So it is called as permanent memory.
Hard Disk: Hard disk is used to store data permanently on computer.
Optical Disks: The Optical Disks are also called as the CD-ROM‟s means Compact
Disk Read Only Memory DVD means Digital Versatile Disk which is also used for Storing
the data into the Disk and this is called as the Optical Disk.
CD – 700 MB DVD – 4.7 GB / 8.5 GB storage capacity.
Algorithm
Algorithm is a set of well defined instructions in sequence to solve the problem.
Advantages of algorithm
It is a step-wise representation of a solution to a given problem, which makes it easy
to understand. An algorithm uses a definite procedure. It is not dependent on any
programming language, so it is easy to understand for anyone even without
programming knowledge. Every step in an algorithm has its own logical sequence so it
is easy to debug. By using algorithm, the problem is broken down into smaller pieces or
steps hence, it is easier for programmer to convert it into an actual program
Flowchart
Circle Connector
Star
t
Read P, N,
R
SI = P * N * R / 100
Print SI
Stop
Merits:
It is makes programming easier than 1GL since it uses mnemonics code for programming. Eg: ADD for
addition, SUB for subtraction, DIV for division, etc.
It makes programming process faster.
Error can be identified much easily compared to 1GL.
It is easier to debug than machine language.
Demerits:
Programs written in this language is not directly understandable by computer so translators should be used.
It is hardware dependent language so programmers are forced to think in terms of computer‟s architecture
rather than to the problem being solved.
Being machine dependent language, programs written in this language are very less or not portable.
Programmers must know its mnemonics codes to perform any task.
2. High level language
Instructions of this language closely resembles to human language or English like words. It uses
mathematical notations to perform the task. The high level language is easier to learn. It requires less time to write
and is easier to maintain the errors. The high level language is converted into machine language by one of the two
different languages translator programs; interpreter or compiler.
Demerits:
It is easier but needs higher processor and larger memory.
It needs to be translated therefore its execution time is more.
Merits:
Easy to program.
Since, the program uses normal sentences, they are easy to understand.
The programs designed using 5GL will have artificial intelligence (AI).
The programs would be much more interactive and interesting.
Demerits:
It is slower than previous generation language as it should be completely translated into binary code
which is a tedious task.
Highly advanced and expensive electronic devices are required to run programs developed in 5GL.
What is Debugging?
Debugging is a methodical process of finding and reducing the number of bugs (or defects) in a
computer program, thus making it behave as originally expected.
There are two main types of errors that need debugging:
Compile-time: These occur due to misuse of language constructs, such as syntax errors.
Normally fairly easy to find by using compiler tools and warnings to fix reported problems.
Run-time: These are much harder to figure out, as they cause the program to generate incorrect
output (or “crash”) during execution. This lecture will examine how to methodically debug a run-
time error in your C code.
J. JAGADEESAN, ASST. PROFESSOR OF COMPUTER SCIENCE, AAGASC,
KARAIKAL-609 605.
8
1. Syntax errors: errors due to the fact that the syntax of the language is
not respected.
2. Semantic errors: errors due to an improper use of program statements.
3. Logical errors: errors due to the fact that the specification is not respected.
From the point of view of when errors are detected, we distinguish:
1. Compile time errors: syntax errors and static semantic errors indicated by
the compiler.
2. Runtime errors: dynamic semantic errors, and logical errors, that cannot
be detected by the compiler (debugging).
1. Identify the Error: A bad identification of an error can lead to wasted developing
time. It is usual that production errors reported by users are hard to interpret and sometimes
the information we receive is misleading. It is import to identify the actual error.
2. Find the Error Location: After identifying the error correctly, you need to go
through the code to find the exact spot where the error is located. In this stage, you need to
focus on finding the error instead of understanding it.
3. Analyze the Error: In the third step, you need to use a bottom-up approach from
the error location and analyze the code. This helps you in understanding the error.
Analyzing a bug has two main goals, such as checking around the error for other errors to be
found, and to make sure about the risks of entering any collateral damage in the fix.
4. Prove the Analysis: Once you are done analyzing the original bug, you need to
find a few more errors that may appear on the application. This step is about writing
automated tests for these areas with the help of a test framework.
J. JAGADEESAN, ASST. PROFESSOR OF COMPUTER SCIENCE, AAGASC,
KARAIKAL-609 605.
9
5. Cover Lateral Damage: In this stage, you need to create or gather all the unit tests
for the code where you are going to make changes. Now, if you run these unit tests, they all
should pass.
6. Fix & Validate: The final stage is the fix all the errors and run all the test scripts to
check if they all pass.
Top-down Design
A top-down approach (also known as stepwise design) is essentially the breaking
down of a system to gain insight into the sub-systems that make it up. In a top-down
approach an overview of the system is formulated, specifying but not detailing any first-
level subsystems. Each subsystem is then refined in yet greater detail, sometimes in many
additional subsystem levels, until the entire specification is reduced to base elements.