Thread: Repeat Until with Multiple Variables?

  1. #1
    Registered User
    Join Date
    Jan 2018
    Posts
    1

    Repeat Until with Multiple Variables?

    I need to make something in my code that will repeat the code until (i) is less or equal to 0, or until (n) is less or equal to zero.

    repeatUntil(i <= 0, OR n <= 0);

    something along those lines

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,791
    Code:
    a:
        if (i <= 0 || n <= 0) goto b;
        /* Do stuff here */
        goto a;
    b:
       /* Now outside of loop */

  4. #4
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    1,106
    No, you should stay away from goto statements!

    while, or do while loops are the proper way to repeat code until a specific condition. for loops if you know the number of iterations.

    Please read the link in @stahta01's post #2

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How can I create multiple variables in C?
    By superbbrr in forum C Programming
    Replies: 1
    Last Post: 10-31-2011, 03:43 PM
  2. multiple nonlocal variables
    By Furious5k in forum C++ Programming
    Replies: 19
    Last Post: 08-24-2011, 09:01 AM
  3. How can this be done - multiple variables stored
    By spadez in forum C Programming
    Replies: 2
    Last Post: 04-14-2009, 10:13 AM
  4. comparing multiple variables..
    By myrddin in forum C Programming
    Replies: 9
    Last Post: 10-16-2007, 07:03 PM
  5. Multiple variables
    By Kaho in forum C Programming
    Replies: 2
    Last Post: 08-18-2005, 04:32 AM

Tags for this Thread