100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4,6 TrustPilot
logo-home
Notas de lectura

structured programming

Puntuación
-
Vendido
-
Páginas
196
Subido en
09-12-2024
Escrito en
2024/2025

Structured Programming: A Brief Overview Structured programming is a programming paradigm that emphasizes the use of well-defined control structures to create clear, understandable, and maintainable code. It emerged in the 1970s as a response to the problems associated with the unstructured and complex programming practices of the time, often leading to "spaghetti code"—code that is tangled, difficult to follow, and error-prone. The core idea of structured programming is that programs should be divided into smaller, manageable blocks (or modules), with well-defined and logical control flows. The primary focus is on improving code clarity, reducing complexity, and making the program easier to debug, maintain, and extend. Here are the key concepts of structured programming: 1. Control Structures Structured programming relies on the use of the following three basic control structures to dictate the flow of the program: Sequence: The default mode of execution, where statements are executed one after another in a linear fashion. Selection (Decision-making): This structure allows the program to make decisions based on conditions. It’s typically implemented using if, else, switch, or case statements. Example: python Copy code if condition: # code block else: # code block Iteration (Loops): Repeating a set of instructions a specified number of times or until a certain condition is met. Common loops include for, while, and do-while. Example: python Copy code for i in range(5): print(i) These three control structures—sequence, selection, and iteration—form the backbone of structured programming. They ensure that the program is easy to follow and that the flow of control is clearly defined. 2. Modularization (Subroutines/Functions) Instead of writing large, monolithic blocks of code, structured programming encourages breaking down the program into smaller, logically organized functions or subroutines. Each function should perform a specific task and be relatively independent of other functions, promoting reusability and maintainability. Functions should have well-defined inputs and outputs (parameters and return values). Each function should ideally do one thing and do it well, which makes it easier to understand and test. Example: python Copy code def add(a, b): return a + b 3. Top-Down Design Structured programming often follows a top-down approach to design, where the problem is broken down into smaller sub-problems. The design starts with the highest-level overview (the main function) and then refines it into more detailed components (individual functions or modules). This approach promotes better organization and ensures that each part of the program serves a specific, logical function. 4. Avoidance of GOTO Statements A hallmark of structured programming is the avoidance of GOTO statements (or jumps) in the code. GOTO can lead to unstructured and unpredictable control flow, making programs difficult to understand and maintain. Instead, structured programming relies on the aforementioned control structures to maintain a clear and predictable flow of execution. 5. Clarity and Readability Structured programming encourages code that is easy to read and understand. This includes: Using meaningful variable and function names. Writing comments and documentation to explain the purpose of code blocks. Following consistent indentation and formatting practices to visually distinguish the structure of the code. 6. Error Handling Error handling in structured programming is usually done using structured mechanisms, such as try-except blocks or predefined error codes, which ensures that errors are caught and dealt with in a controlled manner. Advantages of Structured Programming: Improved Readability: By using well-defined control structures and functions, the flow of the program is clear and easy to understand. Easier Maintenance: Smaller, modular pieces of code are easier to test, debug, and modify. Reduced Complexity: Structured code tends to have fewer bugs and is less prone to errors due to its organized nature. Reusability: Functions and modules can be reused across different parts of the program or in future projects. Example of Structured Programming in Practice: python Copy code # Function to calculate the area of a rectangle def calculate_area(length, width): return length * width # Main function that drives the program def main(): length = float(input("Enter the length of the rectangle: ")) width = float(input("Enter the width of the rectangle: ")) area = calculate_area(length, width) print(f"The area of the rectangle is: {area}") # Calling the main function if __name__ == "__main__": main() In this example: The program is broken into a main function and a helper function (calculate_area), making it easy to understand. The flow of control is structured: the program prompts for input, calculates the area, and outputs the result. There's no use of GOTO statements; the program follows logical control structures (sequence, selection, iteration). Conclusion Structured programming revolutionized the way software was developed, promoting clarity, simplicity, and maintainability. Its principles are still widely followed in modern programming practices, even as newer paradigms like object-oriented programming (OOP) have emerged. By adhering to structured programming practices, developers create code that is easier to read, test, and maintain, which ultimately leads to more reliable software.

Mostrar más Leer menos
Institución
Grado











Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Escuela, estudio y materia

Grado

Información del documento

Subido en
9 de diciembre de 2024
Número de páginas
196
Escrito en
2024/2025
Tipo
Notas de lectura
Profesor(es)
Desconocido
Contiene
Todas las clases

Temas

Vista previa del contenido

LABAN KARIUKI STRUCTURED PROGRAMMING (C)

, CONTENTS
Module: 1
Lecture 1: A Beginner’s Guide

Lecture 2: Introduction to Programming

Lecture 3: Introduction to C, structure of C programming

Lecture 4: Elements of C

Lecture 5: Variables, Statements, Expressions

Lecture 6: Input-Output in C

Lecture 7: Formatted Input-Output

Lecture 8: Operators

Lecture 9: Operators continued…

Lecture 10: Control Statements

Lecture 11: Iterative statements

Lecture 12: Jump statements

Module: 2
Lecture 13: Function

Lecture 14: Function categories

Lecture 15: Actual arguments and Formal arguments

Lecture 16: Recursion

Lecture 17: Recursion verses Iteration

Lecture 18: Storage classes

Lecture 19: Arrays

Lecture 20: Two Dimensional Arrays

Lecture 21: Array using Function

Lecture 22: Strings

, Lecture 23: Common Functions in String



Module: 3
Lecture 24: Structure in C Union

Lecture 25: Nested Structure

Lecture 26: Union

Lecture 27: Pointers

Lecture 28: Pointers and Arrays

Lecture 29: Pointer Arithmetic

Lecture 30: Pointers and Function

Lecture 31: Dynamic Memory Allocation

Lecture 32: Pointer to Structure

Lecture 33: File

Module: 4
Lecture 34: Algorithm and Data Structure

Lecture 35: Analysis of Algorithms

Lecture 36: Storage structure of Arrays

Lecture 37: Sparse Matrices

Lecture 38: Stack

Lecture 39: Queue

References

, MODULE 1
LECTURE NOTE-1



A BEGINNER’S GUIDE
INTRODUCTION TO COMPUTERS

Any programming language is implemented on a computer. Right form its inception, to the
present day, all computer system (irrespective of their shape & size) perform the following 5
basic operations. It converts the raw input data into information, which is useful to the users.

 Inputting: It is the process of entering data & instructions to the computer system.
 Storing: The data & instructions are stored for either initial or additional processing,
as & when required.
 Processing: It requires performing arithmetic or logical operation on the saved data
to convert it into useful information.
 Outputting: It is the process of producing the output data to the end user.
 Controlling: The above operations have to be directed in a particular sequence to be
completed.

Based on these 5 operations, we can sketch the block diagram of a computer.




Fig 1: Block Diagram of a Computer
$17.49
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
Nechemia17 Campbell University
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
139
Miembro desde
4 año
Número de seguidores
124
Documentos
1884
Última venta
7 meses hace
BEST HOMEWORK HELP AND TUTORING ,ALL KIND OF QUIZ or EXAM WITH GUARANTEE OF A

WELCOME TO MY WORLD, GET ALL KIND OF EXAMS ON THIS PAGE, COMPLETE TEST BANKS, SUMMARIES,STUDY GUIDES, PROJECT PAPERS, ASSIGNMENTS, CASE STUDIES AND YOU CAN ALSO COMMUNICATE WITH THE SELLER FOR ANY PRE WORK EXAMS, I ASSURE YOU A SATISFACTORY WORK IF YOU WILL USE MY WORK.

3.9

20 reseñas

5
11
4
1
3
5
2
1
1
2

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes