Module1-Introduction
Module1-Introduction
2024 ADMISSION
C- PROGRAMMING
DAY 1
21-08-2024
COMPUTER
▪Computer :PROGRAMMING
It is a machine which can automatically perform a
computation as instructed to do by a computer program.
represented by an algorithm/flowchart/Pseudocode.
3
PROGRAMMING
LANGUAGE
▪A language which enable communication between a human
▪Example :
4
PROGRAMMING
▪Process of developing or writing a computer program
▪Steps in programming
3. Represent it as an
algorithm/flowchart/p
seudocode
4. Convert this to an
equivalent program in
any programming
language 5
PROGRA
M
▪Computer should be instructed about how to process an instance of a
problem.
▪ Algorithm:
●
English like description representing a step by step procedure
to solve a computational problem.
▪ Flowchart:
●
Diagrammatic representation showing a procedure to solve
a problem
▪ Pseudocode:
●
Short readable and semiformal english like description
ALGORITHM
FLOWCHART, ALGORITHM AND PSEUDO CODE
ALGORITHM
It is a complete step by step representation of the solution of the problem, represented in English
like Languages. An algorithm can be abstract or quite detailed. A detailed algorithm consists of every
step, equivalent to one instruction of a programming language. An algorithm should start with a word
“Start” and end with a word “Stop”.
Examples:
Algorithm to find the area of circle
1. Start
2. Read radius
3. area=3.14*radius*radius
4. Print area
5. Stop
Algorithm to find the sum of two numbers
1. Start
2. Read a, b
3. Sum=a+b
4. Print Sum
5. Stop
●
If no step numbers are given then execution will be in the
order in which they are arranged.
▪Example 1: Develop an algorithm to find the sum of two numbers taken
as input from user.
▪Input : Two numbers
▪Output: Sum of the numbers
Step 1 : Start
Step 2 : Input first number into A
Step 3 : Input second number into B
Step 4 : Perform addition of A and B and store
result in SUM. Step 5 : Display number in SUM as
solution.
Step 6 : Stop
12
Example 2 : Develop an algorithm to find the area of a
rectangle. Input : Length L, Breadth B
Output: AREA
Step 1 : Start
Step 2 : Input the length into L
Step 3 : Input breadth into B
Step 4 : Perform the multiplication of L and B and store
result in AREA Step 5 : Display number in AREA as solution.
Step 6 : Stop
13
Example 3 : Develop an algorithm to find the area and circumference
of a circle. Example 4 : Develop an algorithm to find the largest of 2
numbers.
A, B Output: Largest
Number
Step 1 : Start
Step 2 : Input first
number into
A
Step 3 : Input second
number into B
14
Step 4 : Compare A and B and if A is greater then goto step 5 else
▪Qn: Develop an algorithm to find the maximum of three numbers input
step 6
and go to step 10
Home work
Input : a, b, c
Output : Nature of roots, roots of QE
count = count +1
Step 1 : Start
Step 2 : Let sum = 0, count = 0
count = count +1
step
Step 410Step
: 8 : Average = 1
6
Qn: Read and display a sequence of N integer
numbers Input : value of N, N numbers
Output : Display the
numbers Step 1 : Start
Step 2 : Let i =1
Step 3 : Input value of N
Step 6 : If i <= N Go to
Step 8 : Print
A[i] Step 9 : i
=i+1
1
Step 11 :: If
10 7
Qn: Average of N integer
numbers Input : value of N, Output : Display the
N numbers Average
Step 1 : Start
Step 2 : Let i =1, sum =0
Step 3 : Input value of N
Step 4 : Input number to
S[i] Step 5 : i= i+1
Step 6 : If i <= N Go to step
4 Step 7 : i= 1
Step 8 : Let sum = sum +
S[i]
StepStep
10 : If9 i: <
Let
= iN=Go
i +1
to step
8 Step 11 : Average = sum/N
Step 12 : Print Average
Step 13 : 6
Stop 2
Qn:Find the largest of N numbers.
Input : value of N, the N numbers
Output : Largest number
Step 1 : Start
Step 2 : Let count =0
Step 3 : Input N
Step 4 : Input Number
to A Step 5 : Let
Large = A
Step 6 : If count = N-1 then goto
step
Step 10
8 : Step
If A >7large
: Input Number to
then
Large
A = A Step 9 : Let goto step
count = count + 1 6
Step 10 : Print large
Step 11 :
Stop
22
Qn:Find N! { N! =
1*2*3*........*(N-1)*N }
Input : value of N
Output : N! (or factorial of N)
Step 1 : Start
Step 2 : Let count =1, factn = 1
Step 3 : Input N
count = count + 1
Step 7 : goto
step 4 Step 8 :
23
Qn 1: Write an algorithm to check whether a given number is positive
or negative.
26
Qn: Given a sequence S of N elements and a KEY, find the index of KEY if
present in S
Step 14 : Stop
27
28
FLOWCHART
A flowchart is a diagram that visually represents the steps involved in solving a problem or
carrying out a process. It depicts the possible ways along which the control can flow.
A flowchart can also be defined as a diagrammatic representation of an algorithm.
Flowchart uses many graphical symbols and thus, is more understandable.
The symbol used for different types of statements are as shown.
PSEUDO CODE
It is a more formal representation than the algorithm. Here, we represent
every step in a formal way which is very close to the actual programming
language representation.
In pseudocode, each of the steps will be written via operator and
statements equivalent to some programming language instructions.
The only difference will be that the exact syntax of the programming
language will not be followed.
All pseudocodes will start with the keyword “START” and complete with
keyword “STOP” or “END”.
Computer Architecture
The basic components of a modern digital computer are: Input Device, Output
Device, Central Processing Unit (CPU), and memory.
Central Processing Unit (CPU)
CPU is the brain of the computer system.
All major calculation and comparisons are made inside the CPU and it is
also responsible for activation and controlling the operation of other units.
This unit consists of two major components that are arithmetic logic unit (ALU) and
control unit (CU).
The Memory unit refers to the area where instructions and data are stored in a
computer.
The processor reads instructions and data from the memory, executes them and
writes the result back to it.
The total number of bytes that a memory chip can hold at a time is termed as its
size or capacity.
The memory chips that the processor can directly access are referred to as
primary memory. The three types of primary memory are RAM, ROM and CMOS. RAM is
volatile whereas ROM as CMOS are non-volatile memories. They are metal oxide semiconductor
memory cells built on silicon based ICs.
RAM is a volatile memory and loses its contents when the power is turned off. The circuit is so
designed that any random location can be directly accessed without the need to scroll up or down
the memory.
The program to be executed is loaded into RAM from the non-volatile backup memory.
The processor reads instructions and data from the RAM, executes them and writes data back to
the RAM. Hence RAM is also known as the main memory of the computer.
Everything from the RAM is copied to the non-volatile backup memory before the computer is turned
off. The two main types of RAM are Dynamic Ram (DRAM) and static RAM (SRAM).
Read Only Memory (ROM):
ROM is a non-volatile memory and hence retains its contents even when the computer is
switched off.
It is used for storing software that is rarely changed during the life of the system, sometimes
known as firmware. Almost every computer comes with a small amount of ROM containing the
boot firmware which is essential for the boot-up.
SOFTWARE
Software is a set of instructions that tells the computer about the tasks to be performed and how these
tasks are to be performed.
Program is a set of instructions, written in a language understood by the computer, to perform a
specific task.
A set of programs and documents are collectively called software.
Software is classified into two categories
System Software
Application Software
SYSTEM SOFTWARE AND APPLICATION SOFTWARE
SYSTEM SOFTWARE
System Software is the type of software which is the interface between application software and
computer hardware.
System Software maintains the system resources and give the path for application software to run.
An important thing is that without system software, system cannot run. It is a general purpose
software.
Operating System
OS is a system software which acts as an interface between the user of a computer and computer
hardware. It provides an environment within which the user can execute his programs.
Examples: Microsoft Disk Operating System (MS-DOS), Windows 7, Windows XP, Linux, UNIX,
and Mac OS X Snow Leopard.
APPLICATION SOFTWARE
The software that a user uses for accomplishing a specific task is the application software.
It runs on the platform which is provided by system software. High level languages are used
to write the application software. It is a specific purpose software.
Examples
Word Processing Software: For writing letter, reports, documents etc. (e.g. MS- WORD).
Image Processing Software: For assisting in drawing and manipulating graphics (e.g. Adobe
Photoshop).
The main difference between System Software and Application Software is that without system
software, system cannot run on the other hand without application software, system always runs.
SL. NO SYSTEM SOFTWARE APPLICATION SOFTWARE
Low level languages are used to High level languages are used to
2
write the system software. write the application software.
3 Machine Dependent Machine independent
A translator is a programming language processor that converts a computer program from one
language to another. I
t takes a program written in source code and converts it into machine code. It discovers and
identifies the error during translation.
1. COMPILER
2. INTERPRETER
3. ASSEMBLER
COMPILER
A compiler is a translator used to convert high-level language to machine language.
Eg: gcc, javac, g++.
INTERPRETER
Interpreter is a translator used to convert high-level programming language to low-level programming
language.
Example: Python, jvm(Java Virtual Machine)
ASSEMBLER
An assembler is a translator used to translate assembly language to machine language.
Example: Fortran Assembly Program (FAP), Macro Assembly Program (MAP).
BASIS FOR
COMPILER INTERPRETER
COMPARISON
Input It takes an entire program at a time. It takes a single line of code or
instruction at a time.
Errors Display all errors after compilation, all at Displays error of each line one by one.
the same time.