Skip to content

Procedural Languages

1.2.4 Types of programming language · Paper 1 · 1 flashcard · 1 question

Procedural programming is one of the most common paradigms, especially for learning to program.

Definition
Procedural programming structures programs as a sequence of procedures (functions) that operate on data. The program flows from top to bottom, calling procedures as needed.
Key Point
Key Features of Procedural Programming:
• Programs are sequences of instructions
• Uses the three constructs: sequence, selection, iteration
• Code organised into procedures/functions
• Data and procedures are separate
• Top-down design approach
• Examples: C, Pascal, Python (can be procedural)
Procedural Approach to Calculate Grades:
pseudocode
// Data is separate from procedures
studentScores = [85, 72, 91, 68, 77]

// Procedure to calculate average
function calculateAverage(scores):
    total = 0
    for each score in scores do
        total = total + score
    end for
    return total / length(scores)
end function

// Procedure to determine grade
function getGrade(average):
    if average >= 70 then
        return "A"
    elseif average >= 60 then
        return "B"
    elseif average >= 50 then
        return "C"
    else
        return "Fail"
    end if
end function

// Main program flow
avg = calculateAverage(studentScores)
grade = getGrade(avg)
print("Average: " + avg + ", Grade: " + grade)
Exam Tip
When to use Procedural:
• Small to medium programs
• Problems with clear step-by-step solutions
• Learning to program
• Scripts and automation tasks