• Join over 1.2 million students every month
  • Accelerate your learning by 29%
  • Unlimited access from just £6.99 per month

Explain sequence, selection and iteration as used in computer programming; outline the benefits of having a variety of data types available to the programmer.

Extracts from this document...

Introduction

Code Structure Task Brief * As Gary is fascinated about computer software, he would also like you (a) to explain sequence, selection and iteration as used in computer programming; (b) outline the benefits of having a variety of data types available to the programmer. Contents Task Brief 1 Introduction 1 Sequence Flow 1 Selection / Decision Flow 2 Iteration / Repetition Flow 3 Summery 5 Bibliography 5 Introduction In this report, I shall seek to explain how sequence, selection and iteration are used in computer programming. In order to do so, it first needs to be understood that they are all control structures, and as such are used to help dictate how a program should flow. Sequence Flow In a sequence control structure, statements are processed consecutively, from first to last, with no deviation. No decisions or comparisons have to be made with data, so the program simply runs the instructions and, once the last statement is completed, terminates. The following diagram illustrates this process as a flowchart: (The VB Programmer LLC, 2006) In order to illustrate how this flow appears in practicality, the following is a program I have written in Visual Basic to help illustrate this. ...read more.

Middle

In this case, it prints "That's a big number!" on the screen. * If this is not to the affirmative, it is instructed to follow the else clause, which starts at step 11 and continues onto step 12. In this case it prints, "That is not a big number..." on the screen. * Finally, the end if stated in step 13 encapsulates and signals the end of this process, and the program is allowed to continue processing the instructions as a sequence in step 14. (The VB Programmer LLC, 2006) Iteration / Repetition Flow Instructions are repeated in a loop. The loop can be either a fixed repeat loop (where the loop repeats a specified number of times) or a conditional loop (where the loop will continue until a certain condition has been met). The syntax for implementing these two scenarios differs in Visual Basic, but the basic idea of repeating code until an objective has been completed is the same. The following diagram illustrates this process as a flowchart: (The VB Programmer LLC, 2006) This diagram is simplified to be able to account for both kinds of loops, but the general idea is the same. ...read more.

Conclusion

* The value of total is overwritten by the sum of numbers and the existing value of total in step 8 * The value of counter is overwritten by the sum of 1 and the existing value of counter in step 9 * The program prompts the user in step 10 to enter a number, or to enter X to begin calculating the average of all numbers enters by the user * The user's input is recorded into the numbers variable in step 11 * Finally, this loop statement in step 12 instructs the program that the end of the loop has been reached, and to go back to the beginning of the loop at step 7 Summery In this report, I presented how the control structures sequence, selection and iteration are used in computer programming. We learned that the sequence structure processes instructions in a linear fashion to its conclusion. In regards to selection, we learned that it allows us to create two or more different paths for a program to follow by setting criteria. Finally, we learned that loops allow sections of code to be run either a predetermined or unset number of times, depending on the aim of the loop. ...read more.

The above preview is unformatted text

This student written piece of work is one of many that can be found in our AS and A Level Computer Science section.

Found what you're looking for?

  • Start learning 29% faster today
  • 150,000+ documents available
  • Just £6.99 a month

Not the one? Search for your essay title...
  • Join over 1.2 million students every month
  • Accelerate your learning by 29%
  • Unlimited access from just £6.99 per month

See related essaysSee related essays

Related AS and A Level Computer Science essays

  1. Marked by a teacher

    LAN & Topologies & Data Flow

    3 star(s)

    Any normal server can be transformed into a file server. Indeed a file server is mostly used in a private LAN network, which is probably password protected so user's from outside the network cannot hack it. Ethernet cables are normally used to connect servers to a network.

  2. Peer reviewed

    Principles of Computer Networks

    3 star(s)

    The ring goes around and station wanting to transmit data will take control of it and send it to the destination and when the transmission is completed than the token ring is destroyed and new one is created. IEEE 802.11 Set of standards which put into operation WLAN communication in the 2.4, 3.6 and 5 GHz spectrum band.

  1. Visual basic

    execute specific lines of code and to view the state of variables: o Step Into executes the next line o Step Over executes the next line but skips procedures o Step Out completes the current procedure * The debugging windows are used to view and change the state of variables: o Immediate windows (frequently used with debug.print)

  2. Explain sequence, selection and iteration as used in computer programming; outline the benefits of ...

    If we want to be able to use minus numbers, we also have to be aware that bytes will not be able to support these. (Mark Fishpool, 2011) In this comparison, bytes are less useful, but also happen to be two to four times as efficient when it comes to the amount of reserved space it creates in memory.

  1. Free essay

    What is Visual Programming

    * Visual studio 2005 * Net Beans There are many properties that the languages posses, for example, text boxes, frames, buttons, lists, scroll bars. The only difference is that they have differing names, although not dramatically. The java swing package implements a "J" before the term, jtextbox, jbutton, jpane and so on.

  2. Program Code Program DVD_Program; Uses Menuunit, CRT, dos; ...

    by member', 3, 5); Add_Menu ('Exit', 3,6); Add_Menu ('Set a password', 4, 1); End; {--------------------------------------------------------------------} {This procedure is used to erase the database.} Procedure init_file; VAR response: string; Begin Draw_Box (10, 10, 70, 17); Gotoxy (12, 11); TextColor (15); Writeln ('WARNING!!! THIS PROCEDURE CANNOT BE UNDONE!') Write ('Erase all data?

  1. Investigating Visual Programs

    * Variables declared in a procedure (or undeclared and just used) are "local" to the procedure. * Variables declared in the declarations section of a module are "module", available to all procedures in the module/form. * Variables declared as Public in a module are "global", can be used by all procedures in the program.

  2. CP3 - Proposed Solution to a Realistic Problem - Apartment Administration software

    A magnetic disc back up device will not be necessary because they are used to back up large amounts of data, my program will not save large amounts of data. There are more portable and efficient backup systems that I could advise.

  • Over 160,000 pieces
    of student written work
  • Annotated by
    experienced teachers
  • Ideas and feedback to
    improve your own work