Structured Programming  «Prev  Next»
Lesson 1

Introduction to Programming Fundamentals

This course provides you with a foundation in basic programming concepts that are common to most high-level programming languages with an emphasis on structured programming. You will start by learning what a computer program is and about the environment in which it does its job. As you progress through the course you will move from more general topics, such as how a computer stores numbers and text, to more specific topics, such as how to implement an algorithm for sorting data. Along the way you will have many opportunities to practice your new programming skills by writing computer programs in the Java programming language. By the end of the course you will be ready to study more advanced topics in Java or to move on to another high-level programming language such as C or Visual Basic.

Key Components which make up Structured Programming

Structured programming is a programming paradigm aimed at improving code clarity, maintainability, and efficiency by using well-defined control structures. The key components of structured programming include:
  1. Sequence
    • The execution of statements in a linear, step-by-step manner.
    • Example:
      int a = 10;
      int b = 20;
      int sum = a + b;
      printf("%d", sum);
      
    • Here, the statements execute in the exact order they are written.
  2. Selection (Decision Making)
    • Used to alter the flow of execution based on conditions.
    • Implemented using:
      • if-else
      • switch-case
    • Example:
              if (score >= 50) {
                  printf("Pass");
              } else {
                  printf("Fail");
              }
              
    • The execution path changes based on the score condition.
  3. Iteration (Loops)
    • Used to execute a block of code multiple times.
    • Implemented using:
      • for loop
      • while loop
      • do-while loop
    • Example:
              for (int i = 0; i < 5; i++) {
                  printf("%d\n", i);
              }
              
    • The loop ensures repeated execution until the condition is met.
  4. Modularity (Use of Functions and Procedures)
    • Code is divided into smaller, reusable units (functions or procedures).
    • Promotes maintainability and reusability.
    • Example:
              int add(int a, int b) {
                  return a + b;
              }
      
              int main() {
                  int sum = add(5, 10);
                  printf("%d", sum);
                  return 0;
              }
              
    • The add function can be used multiple times instead of repeating code.
  5. Block Structures (Local Scope and Encapsulation)
    • Code is organized into blocks using {}.
    • Variables have local scope within blocks, reducing unintended interactions.
    • Example:
              {
                  int x = 10; // x is only accessible within this block
                  printf("%d", x);
              }
              
    • This prevents global conflicts and improves code clarity.
  6. Single Entry and Single Exit Principle
    • Each function, loop, or decision structure should have one entry and one exit point.
    • This improves readability and debugging.

Structured programming emphasizes breaking problems into smaller, manageable parts using these principles. It is widely used in languages such as C, Java, and Python, and forms the basis of modern programming methodologies.

Course Goals

After completing this course, you will be able to:
  1. Understand what a computer program is and how it works
  2. Describe how a computer stores numbers and text
  3. Use structured programming concepts
  4. Use the Java 2 Software Development Kit to develop Java programs
  5. Use Java's primitive data types
  6. Use Java's arithmetic, increment and decrement, remainder, relational, and logical operators
  7. Understand numeric promotion, truncation, conversion and casting, and operator precedence
  8. Use control flow constructs in a Java program
  9. Use class methods in a Java program
  10. Use arrays in a Java program
  11. Implement an algorithm for sorting data
C++, Java, and Python focus more on computer logic and less on the presentation. In the next lesson, you will learn about prerequisites to this course.
Programming languages: Perl, Python, Basic,  C++, C#, Javascript, PHP, Java, C
Programming languages: Perl, Python, Basic, C++, C#, Javascript, PHP, Java, C

SEMrush Software