0% found this document useful (0 votes)
8 views2 pages

Structural Programming

Structural Programming is a technique that organizes programs into modules and utilizes control structures like sequence, selection, and iteration, while minimizing the use of goto statements. It offers advantages such as easier debugging and better readability, but can be challenging for large systems. Recursive Programming, on the other hand, involves functions calling themselves to solve problems, relying on a base case and a recursive case.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Structural Programming

Structural Programming is a technique that organizes programs into modules and utilizes control structures like sequence, selection, and iteration, while minimizing the use of goto statements. It offers advantages such as easier debugging and better readability, but can be challenging for large systems. Recursive Programming, on the other hand, involves functions calling themselves to solve problems, relying on a base case and a recursive case.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Structural Programming

Structural Programming is a technique that divides a program into small modules (functions)
and follows a structured flow.

Key Features
• Uses sequence, selection, iteration
• Avoids excessive use of goto
• Divides program into functions

Control Structures
1. Sequence – Step by step execution
2. Selection – if-else, switch
3. Iteration – for, while, do-while
4. Example (C Program)
5. #include<stdio.h>
6. int main() {
7. int a = 5, b = 10;
8. if(a < b) {
9. printf("B is greater");
10. }
11. return 0;
12. }

Advantages

✔ Easy to debug

✔ Better readability

✔ Modular approach
Disadvantages

Difficult for large real-world systems

Recursive Programming

Recursive Programming is a technique where a function calls itself to solve a problem.

Two Important Parts


1. Base Case – Stopping condition
2. Recursive Case – Function calls itself

Example: Factorial using Recursion


#include<stdio.h>

int fact(int n) {
if(n == 0) // Base case
return 1;
else
return n * fact(n - 1); // Recursive call
}

int main() {
printf("%d", fact(5));
return 0;
}

You might also like