Preview

I deserve to be verified on twitter

Good Essays
Open Document
Open Document
733 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
I deserve to be verified on twitter
 What programming techniques or structures can stop or exit an infinite loop?
Sources found on: http://www.dummies.com/how-to/content/breaking-out-of-an-infinite-loop-in-your-c-languag.html & http://www.ehow.com/how_5697840_stop-infinite-loop.html

Loops are programming devices that specify that a section of a program is to be performed one or more times. Typically they are divided into two categories, "for loops" and "while loops". A "for loop" is executed a set number of times. A "while loop" continues to execute until a predefined condition is met. Creating an infinite loop is a very common occurrence for developers

I. Open the source code in the programming software.

II. Identify the infinite loop in the source code. During an infinite loop a program often does not return output or accept input. Start by looking at the code in the area after the last successful input or output action occurred.

III. Insert a line within the loop structure to determine the value of the variable such as in the following Basic language code: while x < 10 print x / line added to monitor variable/ end while

IV. Execute the code and monitor the value of the variable. Determine why the variable is not reaching the value required to fulfill the conditional statement.

V. Modify the source code to satisfy the loop's condition to exit: while x < 10 print x / line added to monitor variable/ x = x + 1 end while

VI. Execute the source code and confirm that the infinite loop has been resolved.

VII. Remove the line of code added to debug the infinite loop.

--------------------------------------------------------------------------------------------------

When you get into programming loops in the C language, you discover the joys and dreads of endless, or infinite, loops. These loops continue forever because either the programmer forgot to include a way to exit from the loop or the exit condition is just never met. Either way, endless loops are a

You May Also Find These Documents Helpful

  • Satisfactory Essays

    PT1420 Chapter 3 Review

    • 1062 Words
    • 8 Pages

    5. Write a pseudocode statement that declares the variable cost so it can hold real numbers.…

    • 1062 Words
    • 8 Pages
    Satisfactory Essays
  • Good Essays

    Week 1 Lab_ CIS_115

    • 439 Words
    • 2 Pages

    List the inputs, any processes/calculations, and the outputs. Use the same valid variable names you used in Step 1.…

    • 439 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    Nt1330 Unit 2 Assignment 1

    • 3740 Words
    • 15 Pages

    1. A while loop will not execute the body of the code if you have your test condition incorrect.…

    • 3740 Words
    • 15 Pages
    Satisfactory Essays
  • Satisfactory Essays

    unit 7 assignment 1

    • 431 Words
    • 2 Pages

    7. Convert the While loop in the following code to a Do-While loop: int x;…

    • 431 Words
    • 2 Pages
    Satisfactory Essays
  • Better Essays

    Program Lovecs.Java

    • 422 Words
    • 2 Pages

    import java.util. Scanner; public class LoveCS { public static void main(String[] args) { Scanner scan=new Scanner(System.in); System.out.println("Enter how many times you wish the message to be printed."); int limit = 0; limit= scan.nextInt(); int sum=0; int count=1; while (count <=limit) { System.out.println(count+" I love Computer Science!!"); sum+=count; count++; } System.out.println("Printed this message " + limit + " times."); System.out.println("The sum of the numbers from 1 to "+limit+" is "+sum); } } import java.util. Scanner; public class PowersOf2 { public static void main(String[]args) { int valuePowersOf2; int nextPowersOf2 =1; int exponent= 0; int count=0; Scanner scan = new Scanner(System.in); System.out.println("Enter A Number.");…

    • 422 Words
    • 2 Pages
    Better Essays
  • Good Essays

    Array Structure Paper

    • 833 Words
    • 4 Pages

    To build an array for Berry’s Bug Blasters the variable must be decided in this case this author knows that the company wants the name from the cuostuomer and the telephone where they are requesting service. Now that the variables are decided the process of building the array can begin. An array must have an Upper Bound. This simply means a limit for the number of times that the loop will run before the program ends. Without this set limit the program would become an infinite loop. Having an infinite loop could likely cause the program to crash in some cases, but it is the opinion of this writer that all that would happen in the case of this program would just mean that the user would be continuously entering data in the way of names and phone numbers with no end to the program. This also…

    • 833 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    Quiz Comp Archi

    • 438 Words
    • 3 Pages

    4) Please describe how the clock works in the digital circuit and what are main concerns on the clock design (performance, power).…

    • 438 Words
    • 3 Pages
    Satisfactory Essays
  • Powerful Essays

    EAS230Syllabus

    • 1748 Words
    • 8 Pages

    C++ programming: editing, compiling, user I/O, variables (ints, doubles, char, strings, booleans), loops, decisions, functions, pointers, arrays, tables, databases, sorting.…

    • 1748 Words
    • 8 Pages
    Powerful Essays
  • Satisfactory Essays

    Unit 4 Homework

    • 401 Words
    • 2 Pages

    When the module is executing, what happens when the end of the module is reached? Computer jumps back to the part of the program that called the module…

    • 401 Words
    • 2 Pages
    Satisfactory Essays
  • Better Essays

    7) Global variables make debugging difficult because any statement in a program can change its value.…

    • 1580 Words
    • 11 Pages
    Better Essays
  • Good Essays

    c) Then a nested IF should test if B15 is equal to the shipping option in D41, and if so, then the value in E41 should be used, otherwise the value in E42 should be used.…

    • 724 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    This Is a Paper

    • 469 Words
    • 2 Pages

    Provide a set of values that will test the normal operation of this program segment. Defend your choices.…

    • 469 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Lab 3 Student

    • 1264 Words
    • 7 Pages

    This lab requires you to think about the steps that take place in a program by writing pseudocode. Read the following program prior to completing the lab.…

    • 1264 Words
    • 7 Pages
    Satisfactory Essays
  • Good Essays

    Macro Examples

    • 1120 Words
    • 5 Pages

    7. The If…Then…Else…End If code allows code to be conditionally executed depending on whether a specified logical condition has been met.…

    • 1120 Words
    • 5 Pages
    Good Essays
  • Powerful Essays

    Atmel Language

    • 1839 Words
    • 8 Pages

    1. 2. 3. Introduction Installing tools for C programming Using AVR Studio for C programming Creating an AVR Studio project Compiling C code to HEX file Debugging C program using the simulator Downloading and running HEX file on AVR board 2 2 3 3 5 6 8…

    • 1839 Words
    • 8 Pages
    Powerful Essays