Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8787303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:51:33+00:00 2026-06-13T21:51:33+00:00

I recall seeing a very elegant for loop construct in C, that would increment

  • 0

I recall seeing a very elegant “for” loop construct in C, that would increment or decrement the loop variable automatically based on whether the initial value was more or less than the end condition value.

In other words, something like this:

fadeUpDown(startVal, stopVal /*, stepSize */ ) {      

    // SOME CODE THAT SETS UP WHETHER TO INCREMENT OR DECREMENT

    for (int i=startVal ; i != stopVal ; ### SOME TRICKY CODE ### ) {    
        // The actual looped code      
    }
}

Having searched quite a bit for this code again, I have had no success, so here I am, asking if someone could help me with this.

Edit: We’re all integers here.
Sanity check on StopVal being an integral increment / decrement of StepSize is outside the scope.
Actually, let’s just skip StepSize and make it 1, in fact.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:51:34+00:00Added an answer on June 13, 2026 at 9:51 pm

    naja, e.g. simple approach:

    int inc=startVal>stopVal?-1:1;
    for (int i=startVal ; i != stopVal ; i+=inc ) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recall seeing a paper a while back for an algorithm that could automatically
I recall seeing, somewhere, an example that stepped through String args[] by deleting the
I recall when I first read Pragmatic Programmer that they suggested using scripting languages
I recall having read somewhere that it is better (in terms of performance) to
I vaguely recall seeing this before in an answer to another question, but searching
I recall hearing or reading somewhere that SELECT * from TABLE where date >=
I recall reading somewhere (I forget where) that if an iPhone application simply ran
I recall in Oracle it is possible to index based on a function, e.g.
I've read somewhere (I dont recall exactly where) that Git (and probably any other
My memory is fuzzy but I seem to recall that Windows Vista introduced an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.