Principle of Programming
Principle of Programming
Programming Developed
Primary Use Cases
Language Year
int main() {
int x = 10, y = 20;
int sum = add(x, y); // Calling a procedure (function)
printf("Sum: %d\n", sum); // Output: Sum: 30
return 0;
}
int add(int a, int b) { // Function definition (procedure)
return a + b; // Simple addition function
}
In this example, the add function encapsulates a small task (adding two numbers), making the
code more organized, readable, and reusable.
Benefits of Procedural Programming:
• Simplicity: Easy to understand and learn, especially for beginners.
• Modularity: Enhances code organization and facilitates debugging.
• Reusability: Promotes reuse of code through procedures.
• Maintainability: Easier to maintain and update due to modular design.
Limitations of Procedural Programming:
• Scalability: May become difficult to manage for large, complex systems.
• Global State Issues: Heavy reliance on global state can lead to issues like unexpected side
effects.
• Less Support for Abstraction: Compared to object-oriented programming, procedural
programming offers less abstraction of real-world concepts.
void drive() {
System.out.println("The car is driving");
}
}