My Math Forum Analogous constructs

 Computer Science Computer Science Forum

 May 11th, 2017, 09:51 AM #1 Member   Joined: May 2014 From: Allentown PA USA Posts: 98 Thanks: 6 Math Focus: dynamical systen theory Analogous constructs Dear MyMathForum Community: There are two types of variable loop constructs in the Pascal language. First, there is the WHILE...DO loop which executes commands WHILE a certain condition is true. Then, there is the REPEAT...UNTIL construct which executes commands UNTIL a certain condition is true. Are there any variable loop constructs that are analogous in C++ and Fortran 90/95 and, if there are, what are they? Thank you. Best regards, Carl Mesaros
 May 11th, 2017, 04:34 PM #2 Senior Member   Joined: Feb 2016 From: Australia Posts: 1,353 Thanks: 464 Math Focus: Yet to find out. A 'while...do' is usually just 'while' in most other languages. Similarly, 'repeat...until' is a 'do...while'. I think Benit mentioned something about syntax in last post. You need to Google the following: "while loop in c++" , "do while loop in c++" to get more details.
May 12th, 2017, 01:28 AM   #3
Senior Member

Joined: Apr 2014
From: Glasgow

Posts: 2,068
Thanks: 692

Math Focus: Physics, mathematical modelling, numerical and computational solutions
Quote:
 Originally Posted by Carl James Mesaros Dear MyMathForum Community: There are two types of variable loop constructs in the Pascal language. First, there is the WHILE...DO loop which executes commands WHILE a certain condition is true. Then, there is the REPEAT...UNTIL construct which executes commands UNTIL a certain condition is true. Are there any variable loop constructs that are analogous in C++ and Fortran 90/95 and, if there are, what are they? Thank you. Best regards, Carl Mesaros
It's actually redundant to use two sets of syntax for those operations. For example, consider the following code:

Code:
int i = 0;
while (i < 5)
{
MyMethod(i);
i++;
}
This loop can either mean "Perform MyMethod(i) until i is 5" or "While i is less than 5, perform MyMethod(i)". There's no difference. That's why more modern languages make no distinction between "repeat until a condition is met" and "repeat whilst a condition is true" and just provide a user with some form of conditional looping.

Last edited by Benit13; May 12th, 2017 at 01:47 AM.

May 12th, 2017, 01:51 AM   #4
Senior Member

Joined: Feb 2016
From: Australia

Posts: 1,353
Thanks: 464

Math Focus: Yet to find out.
Quote:
 Originally Posted by Benit13 It's actually redundant to use two sets of syntax for those operations. For example, consider the following code: Code: int i = 0; while (i < 5) { MyMethod(i); i++; } This loop can either mean "Perform MyMethod(i) until i is 5" or "While i is less than 5, perform MyMethod(i)". There's no difference. That's why more modern languages make no distinction between "repeat until a condition is met" and "repeat whilst a condition is true" and just provide a user with some form of conditional looping.
It's not always redundant... Just most often you use while instead. Besides i don't think that's what OP is asking.. He's simply asking whether the conditional statements perform the same operations in different languages.

 Tags analogous, constructs

 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post Carl James Mesaros Computer Science 3 May 11th, 2017 05:36 AM Math Dreamer New Users 0 June 26th, 2011 11:26 AM

 Contact - Home - Forums - Cryptocurrency Forum - Top