11 doloops

31 %
69 %
Education

Published on March 9, 2014

Author: fyjordan9

Source: slideshare.net

Basic Scientific Programming Repetitive Execution

Program Execution 1. 2. 3. Sequential Statements are executed in a sequential manner, each step being executed exactly once. Selective One of a number of alternative actions is selected and executed. Repetitive One or more steps are performed repeatedly based on a condition result.

Repetition Structure   A repetition structure (loop) makes possible the repeated execution of one or more statements called the body of the loop. Two basic types of repetition 1. Repetition controlled by a counter. 2. Repetition controlled by a logical expression.

Counter Controlled DO Loops    Do Control_variable= initial, limit, step statement sequence End do Control_variable: Counter. Step size must be nonzero.

Example  Do number= 1,5,1 print*, number, number**2 End do Output 1 2 3 4 5 1 4 9 16 25

Example  Do number= 5,1,-1 print*, number, number**2 End do Output 5 25 4 16 3 9 2 4 1 1 Q: what is value of number after exiting the loop??

Example: Summation  This do loop calculates the sum of all integers <= number. sum=0 Do I= 1, number sum= sum+I End do

Examples   Do I = -2, 3 print*, I,” squared=“, I*I End Do Do I= 6, 1, -2 print*, I print* print*, I**2 End Do

Nested Do Loops  The body of a Do Loop may contain another Do Loop. Ex. Do first_loop = 1,4 Do second_loop = 1,4 product= first_loop * second_loop print*, first_loop,second_loop,product End Do End Do

Example Suppose we don’t want duplicates (e.g 2*4, 4*2) Do first_loop = 1,4 Do second_loop = first_loop,4 product= first_loop * second_loop print*, first_loop,second_loop,product End Do End Do

Examples  Do num=1,3 print*, num Do var= num,1,-1 print*, var End Do End Do

Examples  Do I=1,2 Do J= 1,2 Do K=I,J print*, I+J+K End Do End Do End Do

I 1 1 1 1 1 1 2 2 2 2 3 J 1 1 2 2 2 3 1 2 2 3 3 K I+J+K 1 3 2 nothing printed 1 4 2 5 3 nothing printed 3 nothing printed 2 nothing printed 2 6 3 nothing printed 3 nothing printed 3 nothing printed

 User name: Comment:

Related presentations

November 15, 2018

October 31, 2018

Post-holiday seeking Chemistry Tutor

November 14, 2018

Presentacion_4.4

November 14, 2018

H31-321 Cheat Sheet

November 14, 2018

C_SM100_7203 Cheat Sheet

November 14, 2018

Related pages

Programmierung | doloops

Marktforschungen, Branchenanalysen, Statistiken und Marktdaten. Programmierung (Django), Konzeption und Beratung.

Doloops.net, Vienna, Austria. 136 likes. Interessantes aus dem / im Netz Web Apps Entwicklung in Wien/Austria

doloops.de Bewertungen & Erfahrungen | Trusted Shops

70 Bewertungen doloops.de Gesamtnote: sehr gut (4.85) zertifiziert seit 23.10.2013 Kunden sagen: Von Bestellung bis Lieferung hat alles sehr gut ge...

Programmierung | doloops

GenussZeit - Betriebscatering in Premiumqualität. ... Weiterlesen über GenussZeit; die netzwerker

Doloops.net - doloops | Drupal, Python und Webapps aus Wien

Doloops.net befindet sich auf Rang 40.562 in Deutschland. Finden Sie Bewertungen und Erfahrungen zu Doloops.net. Webapps aller Art und Drupal in Wien

Web-Texte – doloops.net – tautscher.net – Kulturkommunikation

Text-Erstellung für die Website doloops.net und die Produktbeschreibungen doq.io und experiencewall. Web-Text „doloops.net“ als pdf ...