C ProgrammingFrequently askedUnit 1
What is an algorithm? Write an algorithm and draw a flowchart to find the largest of three numbers.
5Answer
An algorithm is a finite sequence of clear, unambiguous steps that solves a problem. Every algorithm has input, output, definiteness, finiteness and effectiveness.
Algorithm
Step 1: Start
Step 2: Read a, b, c
Step 3: If a > b and a > c, set largest = a
Else if b > c, set largest = b
Else set largest = c
Step 4: Print largest
Step 5: Stop
Flowchart: an oval Start, a parallelogram Read a, b, c, a diamond a > b and a > c? (Yes → largest = a), a second diamond b > c? (Yes → largest = b, No → largest = c), a parallelogram Print largest, and an oval Stop.