You are on page 1of 8

UNIT 1: Introduction to Programming

● COMPONENTS OF COMPUTER SYSTEM:

1. DISKS: Computer disks refer to various types of storage media


used in computers to store and retrieve digital data. There are
several types of computer disks, including:
HDDs(Hard Disk Drives:magnetic storage devices that use
rotating platters and read/write heads to store and retrieve
data)
SSDs(Solid State Drives: use flash memory to store data)
Optical Disks,etc.

2. MEMORY: Memory is the electronic holding place for the


instructions and data a computer needs to reach quickly. It's where
information is stored for immediate use.
There are technically two types of computer memory: primary and
secondary. The term memory is used as a synonym for primary
memory or as an abbreviation for a specific type of primary
memory called random access memory (RAM).

3. STORAGE: Storage is a mechanism through which digital data is


saved within a data storage device by means of computing
technology either temporarily or permanently.

4. STORAGE vs MEMORY: Memory refers to short-term location of


temporary data (see volatile storage above), while storage
devices, in fact, store data on a long-term basis for later uses and
access. While memory is cleared every time a computer is turned
off, stored data is saved and stays intact until it’s manually deleted.

5. WHERE IS A PROGRAM STORED AND EXECUTED:


Whenever you save your program(anything) into a file (any kind of
file, say ‘add.c’), it automatically gets stored in the secondary
storage i.e. the harddisk. 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)

6. OPERATING SYSTEMS: An operating system is software that


enables applications to interact with a computer's hardware.
An OS performs all the basic tasks like file management, memory
management, process management, handling input and output,
and controlling peripheral devices such as disk drives and printers.
The software that contains the core components of the operating
system is called the kernel.

7. COMPILER: A compiler is a translator that converts the high-level


language into the machine language.
High-level language is written by a developer and machine
language can be understood by the processor.

● ALGORITHMS:
The word Algorithm means ” A set of finite rules or instructions to
be followed in calculations or other problem-solving operations ”.

What is the need for algorithms:


1.Algorithms are necessary for solving complex problems
efficiently and effectively.
2.They help to automate processes and make them more reliable,
faster, and easier to perform.
3.Algorithms also enable computers to perform tasks that would be
difficult or impossible for humans to do manually.
REPRESENTATION OF ALGO:
1.PSEUDOCODES:
Sequence - Is implied by the ordering of the steps in the algorithm.
step 1
step 2
step 3
step 4
step 5

No step can be executed before its preceding step.


Selection - allows for the selective execution of steps based on
some conditional evaluation. We need two forms of selection:
Execute a single alternative
if condition is true
then
perform activity

Execute one of two alternatives


if condition is true
then
perform activity 1
else
perform activity 2

Repetition - allows for execution of the same steps repeatedly, we


don't have to keep writing the same steps over and over and
over....
while condition is true
do
perform activity

2.FLOWCHARTS: Flowchart is a graphical representation of an


algorithm. Programmers often use it as a program-planning tool to
solve a problem. It makes use of symbols which are connected
among them to indicate the flow of information and processing.

Basic Symbols used in Flowchart Designs

1.Terminal: The oval symbol indicates Start, Stop and Halt in a


program’s logic flow. A pause/halt is generally used in a program
logic under some error conditions. Terminal is the first and last
symbols in the flowchart.
2.Input/Output: A parallelogram denotes any function of
input/output type. Program instructions that take input from input
devices and display output on output devices are indicated with
parallelogram in a flowchart.

3.Processing: A box represents arithmetic instructions. All


arithmetic processes such as adding, subtracting, multiplication
and division are indicated by action or process symbol.

4.Decision Diamond symbol represents a decision point. Decision


based operations such as yes/no question or true/false are
indicated by diamond in flowchart.

5.Connectors: Whenever flowchart becomes complex or it


spreads over more than one page, it is useful to use connectors to
avoid any confusions. It is represented by a circle.
6.Flow lines: Flow lines indicate the exact sequence in which
instructions are executed. Arrows represent the direction of flow of
control and relationship among different symbols of flowchart.

● SOURCE CODE: Source code is the fundamental component of a


computer program that is created by a programmer, often written in
the form of functions, descriptions, definitions, calls, methods and
other operational statements. It is designed to be human-readable
and formatted in a way that developers and other users can
understand.

● VARIABLES:
Variables are containers for storing data values, like numbers and
characters.
Eg: int - stores integers (whole numbers), without decimals, such
as 123 or -123

● DATA TYPES:
a data type can be defined as a set of values with similar characteristics.
All the values in a data type have the same properties.

● FORMAT SPECIFIERS:
Format specifiers are used together with the printf() function to tell the
compiler what type of data the variable is storing. It is basically a
placeholder for the variable value.
A format specifier starts with a percentage sign %, followed by a
character.
For example, to output the value of an int variable, you must use the
format specifier %d or %i surrounded by double quotes, inside the
printf() function:
int myNum = 15;
printf("%d", myNum); // Outputs 15
● TYPE CONVERSION:
Type conversion is the process of converting the value of
one datatype to another datatype.

EXPLICIT:
int x = 5;
int y = 2;
int sum = 5 / 2;

printf("%d", sum); // Outputs 2

EXPLICIT:
float myFloat = 9;

printf("%f", myFloat); // 9.000000


● OPERATORS:

Unary operators are the operators that perform operations on a


single operand to produce a new value.
Binary operators are the operators that perform operations on 2
operand to produce a new value.
Ternary operators are the operators that perform operations on a
single operand to produce a new value.

You might also like