Free Essay

Nested Loops

In: Computers and Technology

Submitted By mlee96
Words 323
Pages 2
8.1 Nested Loops
So far our loops have been straight forward. We saw examples of individual loops: pre-test, and post-test, pseodocode and C++ code. And we developed some projects that used the techniques illustrated in the examples. Programming in the real world, however, is seldom so simple. There are many situations requiring nested loops, where we find one loop structure embedded inside another. We will also see nested selection structures embedded in an embedded loop, but that comes later. You are now familiar with the three basic structures necessary to write any program: sequential, selection, and repetition. From now on most of our work will examine how to combine these structures into more and more complex structures. This is similar to the way we learn natural languages. We generally start with words, develop simple sentences, then compound and complex sentences. We then learn how to join sentences into paragraphs using key words to add coherence to our text, and so on. We are doing the same when we learn and eventually master a programming language. We now know the necessary structures and must learn to combine them into meaningful code to solve complex problems. We start with nested loops.
Using any of the techniques we have just learned, try to write a multiplication table for the numbers 1 through 10. Your program should create a table similar to the following:
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
... lines 5-9 skipped to save space
10 20 30 40 50 60 70 80 90 100
Here is the code to generate any of the 10 rows based on user input:
Declare: number, counter counter = 1
Write "Enter a number between 1 and 10: "
Read number
While counter…...

Similar Documents

Free Essay

Single Loop vs Double Loop Learning

...Single loop learning is the most common type of learning and involves problem solving and improving the system but does not seek any answers as to why the problem arose. On the other hand Double loop learning uses feedback from past actions to restructure the set assumption patterns and seek alternative solutions. It is necessary for higher order problem solving and leadership. We see a series of such examples in our daily lives, which involve the use of single loop and double loop learning techniques. As a part of this study we will be analyzing the use of these learning techniques in the implementation of e-governance projects and try to overview whether the replacement of single loop learning with the double loop learning techniques in these mission mode projects yielded better outcomes and results. The study will try to hit the target by being very specific and studying the RajSWAN (Rajasthan State Wide Area Network) Project. The government’s aim behind the implementation of RajSWAN project was to establish an effective communication infrastructure and create a highway for electronic transfer of information in the form of voice, video and data between the various departments of the state machinery with an aim to improve the administrative efficiency and effectiveness of Government programmes and schemes thereby resulting in an improved quality of service to the citizen of this state. It also aims to strengthen the disaster management capacity. RajCOMP is a State......

Words: 1026 - Pages: 5

Free Essay

Double Loop Learning - an Example

...DOUBLE LOOP LEARNING – AN EXPERIENCE This example is a bit too technical, but as I believe that this is a good example from my experience about double loop learning (we used to call this as “Thinking outside the Box”), thought of putting it the least technical form as possible. I was working as a software architect in a particular client’s team. That software system was pretty old and matured (the system was in existence for the past 20 years) and hence we used to treat the existing guidelines in use as the best available. As the system consisted of several hundred independent software programs (also known as modules), each of those has to pass a huge amount of data (names, addresses, other program related data etc.) between them during the operation. As a standard and also to ensure conformity, they used to employ a pre-defined structure to pass data (which will have a fixed size limit with each field having specific starting and ending locations. for e.g.: For address, the first name will be there in the first 30 characters of that structure and middle name will be coming in the next 30 and then comes the last name, followed by address line 1 and 2, each of which is 35 characters in length etc.). The flip side of this is that, even though you are introducing a new field in this predefined structure only for a couple of modules in this 700+ modules system, you will have to modify all the 700+ components to be able to maintain the same structure across, as else, the data......

Words: 696 - Pages: 3

Premium Essay

Loop Capital Case

...Finance 469 January 23, 2013 Case 1: Loop Capitol 1. Reynolds Strengths * Educated * Very Social * Confident in his abilities in the business world * According to the reading he seems like he carries himself in a high classed way * Enjoys his job * Daring Reynolds Weaknesses * Cocky, however in more of a hidden way. He doesn’t just come out and flaunt himself; instead he converse’s with people in a way that makes him seem better than others. * Daring: although I put this in strengths too, I think that being too daring can be bad thing, it is almost as if Reynolds doesn’t know when to stop * Lack of morals in my personal opinion when he used employees to build up his business, rather than training them to make them better and grow with the company 2. Reynolds strategy seemed to work for him in the long run; if I were daring like him and willing to put myself and my business on the line to make it grow then yes I would agree with how he started up his company. However, if I had very little connections and a lot to lose I would not even start up as big as a company as he and his partner did. Even though he was successful in it, I just don’t think I would take that many risks, let alone quit such a great job he had. 3. Based on the case, Reynolds seemed to change his thoughts on how he made a decision for the company. At first he said that capital, people, and distribution would satisfy a growing company. However, later...

Words: 523 - Pages: 3

Free Essay

Heightened Social Anxiety; Moral Panics and Deviancy Amplification Loops.

...coined by Jock Young (1971:37) in his book ‘Images of Deviance’, edited by Stanley Cohen, his peer and colleague. It was Cohen (1973:9) though, in fact, who brought the phrase to the forefront of sociology and defined it when he said: Societies appear to be subject, every now and then, to periods of moral panic. A condition, episode, person or group of persons emerges to become defined as a threat to societal values and interests; its nature is presented in a stylised and stereotypical fashion by the mass media (Cohen 1973:9). This paper assess’ Cohen’s’ ‘moral panic’ as a useful notion for explaining increased social anxiety about criminal behaviour using his work on ‘mods and rockers’ and Wilkins (1964:90) ‘Deviancy Amplification Feedback Loop’, a cyclic process that alienates perpetrators and increases sensitization to their actions creating more frequent arrests and often harsher punishments. Moral panics come and go and more often than not the ‘problem’ has been around for many years before it becomes accepted as a phenomenon that requires attention and reform. Often these moral panics are scapegoats of bigger issues in society (Goode & Ben-Yehuda, 2002:26). Such as Dungeons and Dragons (D&D) in the 1980’s being blamed for youth suicide in America after James Dallas Egbert III and Irving Pulling shot themselves in 1980 and 82 respectively, leading Pulling’s mother to set up B.A.D.D (Bothered About Dungeons and Dragons, which incited that D&D promoted......

Words: 2385 - Pages: 10

Free Essay

Single Loop Learning vs Double Loop Learning

...Nadja Hill HAD assignment 4 9/25/13 Single loop learning is when individuals solve an issue by simply looking at the organization’s policies, values, and rules to come up with a solution. This learning form allows people to follow a process that’s been put in place in order to resolve a problem. Single loop learning is for simple problems that can be fixed by knowing what’s expected from looking at past events and comparing the results. This is considered the simplest learning form. This is a good learning form for an organization because it can lead to adaptive learning. People will begin to adjust to certain processes because of certain changes that take place. When individuals see a certain process repeatedly, they will tend to reflect those behaviors. For example, an organization is trying to limit the amount of slip and falls especially during rainy weather. Problems solvers discover that these accidents are taking place because of the access waters that drips off the umbrellas once the individual is inside the building. So now a way for them to minimize slips and falls is to provide plastic covers to everyone entering in with wet umbrellas. The organization installed appliances with these plastic covers at every entrance with a sign instructing people to take one. Now everyone knows to grab a plastic cover when entering the building when applicable. Double loop learning is when problem solvers or individuals eliminate issues by looking at organizations policies,...

Words: 562 - Pages: 3

Free Essay

Phase Locked Loop

...Xiao-Qiang GUO, Wei-Yang WU, He-Rong GU Yanshan University Phase locked loop and synchronization methods for gridinterfaced converters: a review Abstract. Phase locked loop and synchronization techniques are one of the most important issues for operating grid-interfaced converters in practical applications, which involve Distributed Power Generation Systems, Flexible AC Transmission Systems (FACTS), and High Voltage Direct Current (HVDC) Transmission, and so on. This paper presents a comprehensive review of the recently developed phase locked loop and synchronization methods, then a comparison and selection guide are provided. Finally, a list of more than 40 technical papers is also appended for a quick reference. Streszczenie. Techniki PLL i synchronizacji są ważnymi elementami przetworników w systemach sieciowych, takich jak: rozproszonych systemach mocy, FACTs czy HVDC. Artykuł przedstawia przegląd tego typu metod a następnie porównanie tych metod. Na końcu ponad 40 podstawowych artykułów z tej tematyki jest przedstawionych.(Metody synchronizacji i PLL w przetwornikach sieciowych – przegląd). Keywords: Grid-interfaced converters, phase locked loop, synchronization Słowa kluczowe: uchłady PLL, synchronizacja. Introduction The basic phase locked loop (PLL) concept was originally published by Appleton in 1923 and Bellescize in 1932, which was mainly used for synchronous reception of radio signals [1-2]. After that, PLL techniques were widely used in various......

Words: 5211 - Pages: 21

Premium Essay

Argyris Double Loop Learning

...115 Double loop learning in organizations By uncovering their own hidden theories of action, managers can detect and correct errors Chris Argyris Why are employees reluctant to report to the top that one of their company's products is a "loser" and why can't the vice presidents of another company reveal to their president the spectacular lack of success of one of the company's divisions? The inability to uncover errors and other unpleasant truths arises from faulty organizational learning, says this author. Such habits and attitudes, which alJow a company to hide its problems, lead to rigidity and deterioration. The author descrihes how this process can be reversed hy a method he calls double loop learning. Chris Argyris is James Conant Professor of Education and Organizational Behavior at Harvard University, and is the author of numerous publications on executive leadership and organizational effectiveness. Several years ago the top management of a multibillion dollar corporation decided that Product X was a failure and should be dropped. The losses involved exceeded $ioo million. At least five people knew that Product X was in serious trouble six years before the company decided to stop producing it. Three were plant managers who lived daily with the production problems. The two others were marketing officials, who perceived that the manufacturing problems could not be solved without expenditures that would raise the price of the product to the point where...

Words: 2130 - Pages: 9

Premium Essay

Construction of Loop (Saidabad Side) of Khilgaon Flyover Project

...Project Summary of Construction of Loop (Saidabad Side) of Khilgaon Flyover Project Course Name: International Project Management Course Code: IB-509 Submitted To: Suborna Barua, Assistant Professor, Department of International Business, University of Dhaka Submitted By: Sl. No | Name | Roll No. | 01. | H. M. Rubayyiat Quayyum | 20 | 02. | Md. Mizanur Rahman | 31 | 03. | Md. Sajib Hossain | 32 | 04. | Md. Alauddin Akash | 34 | MBA 6th Batch Department Of International Business University of Dhaka Date: May 27, 2014 Construction of Loop (Saidabad Side) of Khilgaon Flyover Project * Summary of needs and request for action: The government undertook a number of remedial measures to address the public sufferings caused by intolerable traffic congestions in Dhaka city. As a part of the total initiatives to improve the traffic situation in Dhaka the then government approved the Khilgaon Flyover project in the ECNEC meeting on 09/02/2000. Accordingly LGED constructed the flyover which was opened for traffic from March 2005. However, the implementation was not done as per original plan/design because the subsequent government (2001-2006) dropped one of the important loops (Saidabad side) from the project. This has seriously constrained the objectives and expected benefits of the flyover as originally planned. Till now the large volume of traffic coming from Progoti Sarani and eastern part of the city (Mothertek, Kadamtali, Basabo, Shepaibag, Meradia, Goran) can not use...

Words: 452 - Pages: 2

Free Essay

Exploring the Differences Between Count-Controlled Loops and While Loops

...PT1420 Research Assignment 8.1 Exploring the Differences between Count-controlled Loops and While Loops August 14, 2014 Count-control loops are performed a specific number of times while While loops are performed based upon whether a condition is true or not. The process of a While loop is based upon a condition which is dependent upon Boolean expressions. For While and Do While loops, if the expression is true the loop is executed. If the condition is false the loop is exited. A While loop is a pretest loop, which means that the condition is tested before performing an iteration. The Do-While loop is a posttest loop meaning that the loop is executed once before the condition is tested. (Gaddis, 2010) Three reasons a count-controlled loop can be better than a condition-controlled loop include: the fact that it keeps count of the number of times you to input data, it only runs the specific number of times you have instructed the program to, and it will stop after to allotted time instructed. Three reasons condition-controlled loops are more advantageous than count-controlled loops include the fact that the variable can be more than one number as long as the condition is true, condition controlled loops will only stop when the condition is false (or true as in the case of the Do-Until loop), and the variable numbers can be any real number which will make the statement true. References: Gaddis, T. (2010). Starting out with programming logic and design. ......

Words: 288 - Pages: 2

Premium Essay

Poop a Loop

...F14 MGT 4900 Exam #1 Review Questions for Chapters 1 to 4 Chapter 1 1. What do we mean by strategy? See pages 4, 5, and 7 (the first two paragraphs). 2. Why a company’s strategy evolves over time? See page 8. 3. What is the difference between a company’s strategy and a company’s business model? See pages 5, 7 (first two paragraphs), and 10. 4. What are the three tests of a winning strategy? See page 12. 5. What are the telling signs of a well-managed company? See p. 13, the paragraph above the heading “The Road Ahead.” 6. What does a company’s strategy concern? See page 4. 7. The crux of strategy formulation is to develop a sustainable competitive advantage. See pages 5 and 7 (the first two paragraphs). 8. What are the strategy elements of a proactive strategy? See p. 9, first paragraph. Chapter 2 1. What are the five tasks of the strategy-making, strategy-executing process? See page 19 and Figure 2.1 on page 20. 2. What does a company’s strategic vision describe? See p. 21 (first paragraph). 3. What does a company’s mission statement address? See page 24, the paragraph above the last paragraph. 4. What is the difference between the company’s mission statement and the company’s strategic vision? See page 24, margin note to the left. 5. What should well-stated objectives be like? See page 27, the last paragraph of the page. 6. What is the meaning of “strategic intent”? See page 28,......

Words: 874 - Pages: 4

Premium Essay


...Shakespeare's Birthplace is a restored 16th-century half-timbered house situated in Henley Street, Stratford-upon-Avon, Warwickshire, England, where it is believed that William Shakespeare was born in 1564 and spent his childhood years.[1][2] It is now a small museum open to the public and a popular visitor attraction, owned and managed by the Shakespeare Birthplace Trust.[3] It has been referred to as "a Mecca for all lovers of literature".[4] William Shakespeare [3] was born in Stratford-upon-Avon, a market town of around 1,500 residents about 100 miles (160 km) northwest of London. The town was a centre for the slaughter, marketing, and distribution of sheep, as well as for hide tanning and wool trading. The exact date of his birth is not known but has been traditionally taken to be April 23, 1564, which is also the Feast Day of Saint George, the patron saint of England. Shakespeare's baptismal record was dated 26 April 1564. He was the first son and the first surviving child in the family; two earlier children, Joan and Margaret, had died early.[4] John Shakespeare's house, believed to be Shakespeare's birthplace, now belonging to the Shakespeare Birthplace Trust He was the son of John Shakespeare, a successful glover originally from Snitterfield, and of Mary Arden, the youngest daughter of John's father's landlord. The Ardens were members of the local gentry. The couple married around 1557 and lived on Henley Street when Shakespeare was born in a house now known as...

Words: 494 - Pages: 2

Premium Essay

Loops in the Python Programming Language

...What are the benefits of using loops in programming? Using the lecture and internet, research examples of loops in python and describe their functions. What is an example of a loop you might see in the real world? In programming, the use of loops allows a programmer to simplify repetitious tasks with a process that will repeat itself over a series of passed values whether it is form a user passed parameter or a store set of data (for example, pulling a set of data form a database and “looping” through it to perform a series of checks). The loop function in Python is called using the “for” statement where it will repeat a series of event in a sequence. The syntax in Python will be: for {element_to_repeat} in {sequence}: Do something here An example of this could be to output a user’s name on screen in a line break format such as: userName = ‘Paul’ for letter in UserName: print ‘Letter – ‘, letter print ‘That spells ‘, userName The use of loops in a real world example could be to validate if a series of values falls into a specific range. This may include something such as determining if a set of salaries was higher or lower than a national average. In a previous example, we wrote code that would determine how many years remained in a set of employees until they retired. In my work, I often use loops to run through a set of product serial numbers and determine if each one is in a manufacturer’s warranty or not prior to us shipping products....

Words: 265 - Pages: 2

Premium Essay

Phase Lock Loop

...STATISTICS I EMGT 571 Assignment 1 Instructions: This assignment is designed to test your ability to work with SPSS and excel statistical software applications. Answer the following question using appropriate graphs and descriptive statistics generated from SPSS and/or excel. The attached excel file (Social_Climbers.xls) contains data obtained from 274 couples regarding their education level, annual salary, the value of the cars that they own, the value of their homes, their total savings value (including stocks and bonds) and their social climber index (scale of 1-10, where 1 means very unconcerned about social status, 10 means very concerned). With this data and using SPSS and/or excel statistical functions, answer the following questions: a) Generate box plots that illustrate education level versus salary, and social climber index versus salary. Briefly explain what you learn from these box plots with regards to salary vs. education level and salary vs. social climber index . b) Generate histograms and descriptive statistics for the following variables: salary, car value, home value and total savings. Be sure to identify median, mean, and standard deviation also identify any trends or abnormalities that are obvious. c) Generate histograms and descriptive statistics for the same variables in part b except segregate these by education level. (Essentially you will get 4 sets of descriptive statistics on salary, car value, home value and savings......

Words: 336 - Pages: 2

Free Essay

System Dynamics and Feedback Loop

...Topic: System dynamics and feedback loop System dynamics is an approach to understanding the behavior of complex systems over time. It deals with internal feedback loops and time delays that affect the behavior of the entire system. System dynamics use feedback loops and stocks and flows to study complex and non-linear systems. Dynamics of the system contain quantities that vary over time. There are several laws of Fifth Discipline showing how system dynamic works. 1) For every action, there is a reaction. It is self-proofed in the beer game. Every order has to be fulfilled, either in the current week (if enough stock is available) or in one of the next weeks (items go on backorder). 2) Short-term improvements often lead to long term difficulties. In the beer game, it’s always a tradeoff between fulfilling demand and minimizing cost. Timely delivery calls for enough inventory, while cumulative inventory results in climbing inventory cost, due to more people to handle the beer and more storage space, and there is also a possibility that the beer will be left in your inventory when the total period is over or the redundant beer might go bad since it cannot be kept long. 3) Cause and effect are not necessary closely related, either in time or in space. Sometimes solutions implemented here and now will have impacts far away at a much later time. In the beer game, it is not possible for any one component of the system to be immediately aware of the actions and needs......

Words: 1255 - Pages: 6

Premium Essay

The Missing Link in the Loop of Movies, Destination Image and Tourist Behavior

...Social Distance The Missing Link in the Loop of Movies, Destination Image, and Tourist Behavior? Journal of Travel Research Volume 47 Number 4 May 2009 494-507 © 2009 SAGE Publications 10.1177/0047287508326534 hosted at Asli D. A. Tasci The Hong Kong Polytechnic University Visual information, especially delivered through movies, is believed to have an influence on destination image and consumer behavior. Based on the theory that knowledge about an object might cause feelings toward the object, visual information through movies can be assumed to affect not only destination image but also social distance between groups and, thus, to affect tourist behavior regarding the destination. With a quasi-experimental design, this study investigates if there is a relationship between visual information from movies and consumer-behavior variables, including destination image, destination desirability, visit intention, and social distance, taking Turkey as a case in point and a promotional movie as the stimuli. Results provide partial support for potential impact of movies on the consumer-behavior variables included in this study. Implications and future research suggestions are provided. Keywords: A destination image; visual information; social distance; stereotypical image; Turkey mong the several factors that impact destination image, the influential role of information provided by the visual media, such as movies, has been......

Words: 10268 - Pages: 42