cse syllabus
cse syllabus
Programming Language
Department of
Computer Science &
Engineering
www.cambridge.edu.in
Algorithm , Flowchart & Pseudocode
What is an Algorithm?
Algorithm is a set of well-defined instructions in sequence to solve a problem.
Labeled Connectors:
Represented by a circle with an identifying label.
Used in complex or multi-sheet diagrams to replace arrows and maintain
clarity.
Symbols used in Flowchart
Flowchart
Algorithm Flowchart
Write a C Program to add 2 numbers.
Algorithm
Step 1: [ Initialization ]
Start
Step 2: [ Input 2 no’s from the user ]
Read num1, num2
Step 3: [ Add num1 and num2 and
assign the result to a variable sum ]
Sum = num1 + num2
Step 4: [ Display sum ]
Print Sum
Step 5: [ Finished ]
Stop
Algorithm Flowchart
Write a C Program to find area of circle.
Step 1: [ Initialization ]
Start
Step 2: [ Input radius from the user ]
Read radius
Step 3: [ Compute Area ]
area =PI * radius*radius
Step 4: [ Display Area ]
Print area
Step 5: [ Finished ]
Stop
Algorithm Flowchart
Design and develop a C program to read a year as an input and find whether it is leap year or not.
Step1: [Initialization]
Start
Step2: [Input year]
Read year
Step3:[Check whether
given year is leap year
or not]
if ( ((year%4==0) &&(year%100!=0))||
(year%400 == 0))
Display leap year
else
Display not a leap year
Step 4:[finished]
stop
• How to Find a Leap Year Using C?
• To find whether a year is a leap year or not using a leap year C program, all
you need to do is enter some conditions (mathematical) in the program
code with the help of If… Else statement; Following are the conditions to
check if the given year is a leap year or not:
Overview:
• SDLC: A systematic approach used in modern software development.
• Waterfall Model: A widely recognized SDLC model with distinct phases
that follow a linear progression.
Phases of the Waterfall Model:
1.Systems Requirements: Define what the proposed system should
accomplish.
2.Analysis: Evaluate different approaches from a systems perspective.
3.Design: Define individual program functions and complete file/database
designs.
4.Coding: Write programs based on design specifications.
5.Testing: Test all programs together to ensure the system works as intended.
6.Maintenance: Maintain and support the system after deployment.
Key Points:
•Iteration: Despite the linear flow, revisiting and reworking earlier phases is
common due to errors or changes.
System Development Life Cycle (SDLC)
Program Development
Develop a Solution: Plan how to convert given inputs into the specified
outputs. This constitutes the core of program design.
Test the Program: Validate the program through testing to ensure it functions
as expected.
Program Development
Once we fully understand the problem and have clarified any questions, we
proceed to develop our solution. This process is supported by three main
tools:
• structure charts
• pseudocode
• flowcharts.
Typically, we use a structure chart to design the entire program, while either
pseudocode or flowcharts are employed to design its individual parts or
modules.
Structure chart for an Email server
Program Development
START Declare
2. Pseudocode inthree variables: num1, num2, num3 Input num1,
C Programming
num2, num3
Pseudocode in IF
C num1 >= num2
programming AND the
describes num1logic>=
of num3 THEN
a program in alargest =
num1 ELSEhuman-readable
structured, IF num2 >= num1 AND num2
form before >= num3
actual coding. It isTHEN largest
not specific to =
C
num2 ELSE
syntax but largest
can = num3
be easily END
translated IF C
into Print "The largest number is"
code.
largest
ExampleENDSTART
Pseudocode: Declare threetovariables:
C Program num1,of
Find the Largest num2,
Threenum3
Numbers
BEGIN
Declare three variables : A, B, C
Input A,B,C //Read three numbers
IF A>=B && A>=C
largest = A
ELSE IF B>=A && B>=C
largest = B
ELSE
largest=C
END IF
Print “ The largest number is “ l
END
Program Development
START Declare
3 Flowchart in Cthree variables: num1, num2, num3 Input num1,
Programming
num2, num3inIFCnum1
A Flowchart >= num2
programming ANDrepresents
visually num1 >=the num3
logic THEN
of a C largest
program=
num1 ELSE IF symbols
using standard num2 >= num1various
to depict AND num2 >= num3
operations THEN
and flow largest =
of control.
num2
Example ELSE largest =Cnum3
Flowchart: END
Program toIFFind
Printthe
"The largest
Largest number
of Three is"
Numbers
largest ENDSTART Declare three variables: num1, num2, num3
Program Development
Process:
•Test plans are based on the requirements statement.
•Performed by system test engineers and users.
•Helps ensure the system works as expected.
Importance:
•Reviewing test plans early helps clarify requirements and guide development.
Program Development
START Declare
2. Whitebox three variables: num1, num2, num3 Input num1,
Testing
num2, num3 IF num1 >= num2 AND num1 >= num3 THEN largest =
Overview:
num1 ELSE
•Testing withIFfull
num2 >= num1
knowledge AND
of the num2internal
program's >= num3 THEN largest =
structure.
num2 ELSE by
•Performed largest = num3 END IF Print "The largest number is"
the programmer.
largest ENDSTART Declare three variables: num1, num2, num
3Process:
•Test every instruction and possible scenario.
•Treat the program like a "glass house" where everything is visible.
Structure of functions:
Divided into two sections:
Declaration section: Describes the data used in the function (local
o
statements
Preprocessor commands:
Special instructions to the preprocessor for preparing the program for
o
compilation
o One common preprocessor command is include
Purpose of Comments
Clarify code, serve as documentation, ignored by the compiler.
Block Comments
Syntax:
• Starts with /*, end with */
• Spans multiple lines
Example:
/*
Name of Program:
Date:
Description:
*/
Line Comments
Syntax:
•Start with //
•For single-line comments
•Example: