EIT - CO2 - Programming Fundamental (CO2)
EIT - CO2 - Programming Fundamental (CO2)
COURSE NAME:
INTRODUCTION TO
INFORMATION TECHNOLOGY
mmmV (EIT)
COURSE CODE: 22CA1103
Topic:
PROGRAMMING
FUNDAMENTAL (CO2)
Prepared by: Dr. Taushif Anwar
Assistant Professor, CSA Module - 2
CREATED BY K. VICTOR BABU
AIM OF THE SESSION
To enable students grasp the basics of programming, such as basic syntax in the program, writing
algorithms, using flowcharts, as well as testing and debugging the program to fix its errors.
INSTRUCTIONAL OBJECTIVES
LEARNING OUTCOMES
8
CREATED BY K. VICTOR BABU
STEPS FOR PROBLEM SOLVING
• Analyzing the problem
• It is important to clearly understand a problem before
we begin to find the solution for it.
• We need to read and analyze the problem statement
carefully.
• By analyzing a problem, we would be able to figure
out what are the inputs that our program should accept
and the outputs that it should produce.
9
CREATED BY K. VICTOR BABU
STEPS FOR PROBLEM SOLVING
• Developing an Algorithm
• It is essential to device a solution before writing a
program code for a given problem.
• The solution is represented in natural language and is
called an algorithm.
• An algorithm is a plan for solving a problem.
10
CREATED BY K. VICTOR BABU
STEPS FOR PROBLEM SOLVING
• Coding
• After finalizing the algorithm, we need to convert the
algorithm into the format which can be understood
by the computer to generate the desired solution.
• Different high level programming languages can be
used for writing a program.
• Record the details of the coding procedures followed
and document the solution.
11
CREATED BY K. VICTOR BABU
STEPS FOR PROBLEM SOLVING
• Testing and Debugging
• The program tested on various parameters.
• The program should meet the requirements
of the user.
• It must respond within the expected time.
• It should generate correct output for all possible inputs.
• In the presence of syntactical errors, no output will be
obtained.
• In case the output generated is incorrect, then
the program should be checked for logical errors, if any.
12
CREATED BY K. VICTOR BABU
ALGORITHM
• An algorithm is defined as a step-by-step procedure
designed to perform an operation which will lead to
the desired result, if followed correctly.
18
CREATED BY K. VICTOR BABU
ALGORITHM
## Algorithm for average of three numbers
Step 1: Start
Step 2: Read A, B, C
Step 3: Avg=(A+B+C)/3
Step 4: Print Avg
Step 5: Stop
19
CREATED BY K. VICTOR BABU
REPRESENTATION OF ALGORITHMS
• Flowchart - visual representation of algorithms
20
22
CREATED BY K. VICTOR BABU
Flowchart
## Write an algorithm to check whether a number is
odd or even
23
CREATED BY K. VICTOR BABU
Pseudocode
• A pseudocode is another way of representing an algorithm.
25
CREATED BY K. VICTOR BABU
Pseudocode
• Pseudocode for the sum of two numbers will
be:
INPUT num1
INPUT num2
COMPUTE Result = num1 + num2
PRINT Result
26
CREATED BY K. VICTOR BABU
Pseudocode
• Pseudocode for calculating area and perimeter of a
rectangle.
Input length
Input breadth
compute area = length * breadth
print area
compute perim = 2 * (length +
breadth)
print perim
27
CREATED BY K. VICTOR BABU
Assignment
Step-1 Start
Step-2 Input Two Numbers Say NUM1, NUM2
Step-3 Display Before Swap Values NUM1, NUM2
Step-4 TEMP = NUM1
Step-5 NUM1 = NUM2
Step-6 NUM2 = TEMP
Step-7 Display After Swap Values NUM1, NUM 2
Step-8 Stop Algorithm
STEP 1: START.
STEP 2: ENTER NUM1, NUM2.
STEP 3: PRINT NUM1, NUM2.
STEP 4: NUM1 = NUM1 + NUM2.
STEP 5: NUM2 = NUM1 – NUM2.
STEP 6: NUM1 = NUM1 – NUM2.
STEP 7: PRINT NUM1, NUM2.
STEP 8: END