data-driven-docs

Selft training repo


Project maintained by ggranados Hosted on GitHub Pages — Theme by mattgraham

Imperative Programming


Table of Contents


What’s Imperative Programming

Imperative programming focuses on explicitly specifying a sequence of statements that modify program state. It emphasizes how to achieve a result through step-by-step instructions and control flow structures like loops and conditionals.

Procedural programming and structured programming are subsets of imperative programming.

Back to top

Languages

Procedural and object-oriented programming (OOP) languages fall under imperative programming, such as C, C++, C#, and Java.

Back to top

Examples

The example calculates the sum of numbers from 1 to 10 using a for loop in Java.

int sum = 0;
for (int i = 1; i <= 10; i++) {
    sum += i;
}
System.out.println("Sum: " + sum);

Declarative style is a contrast to the Imperative style

Back to top


Ref.


Get Started | Java