My Math Forum  

Go Back   My Math Forum > Science Forums > Computer Science

Computer Science Computer Science Forum


Reply
 
LinkBack Thread Tools Display Modes
May 11th, 2017, 10:51 AM   #1
Senior Member
 
Joined: May 2014
From: Allentown PA USA

Posts: 102
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
Carl James Mesaros is offline  
 
May 11th, 2017, 05:34 PM   #2
Senior Member
 
Joined: Feb 2016
From: Australia

Posts: 1,461
Thanks: 489

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.
Joppy is offline  
May 12th, 2017, 02:28 AM   #3
Senior Member
 
Joined: Apr 2014
From: Glasgow

Posts: 2,081
Thanks: 698

Math Focus: Physics, mathematical modelling, numerical and computational solutions
Quote:
Originally Posted by Carl James Mesaros View Post
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 02:47 AM.
Benit13 is offline  
May 12th, 2017, 02:51 AM   #4
Senior Member
 
Joined: Feb 2016
From: Australia

Posts: 1,461
Thanks: 489

Math Focus: Yet to find out.
Quote:
Originally Posted by Benit13 View Post
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.
Joppy is offline  
Reply

  My Math Forum > Science Forums > Computer Science

Tags
analogous, constructs



Thread Tools
Display Modes


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





Copyright © 2017 My Math Forum. All rights reserved.