What is imperative and declarative programming
What is imperative and declarative programming Learn Java Imperative programming is a programming style where you tell the computer exactly what steps to perform, and in what order . Think of it like giving someone a recipe: Get some flour. Add water. Mix them. Bake the mixture. In programming, you might write: x = 5 y = 10 sum = x + y print(sum) The program executes these instructions sequentially: Store 5 in x Store 10 in y Add x and y Store the result in sum Print sum Key characteristics Imperative programs commonly use: Variables — store changing data Assignment — change the value of variables Loops — repeat instructions Conditionals — choose which instructions to execute Functions/procedures — group instructions together Statements — individual commands that change the program's state For example: total = 0 for i in range(1, 6): total = total + i print(total) Here, total changes state as the program runs: 0 → 1 → 3 → 6 → 10 → 15 ....