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

  • SEARCH
  • Home
  • 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 8466343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:18:46+00:00 2026-06-10T15:18:46+00:00

I did a Compilers course and now I’m practicing for my exam. One of

  • 0

I did a Compilers course and now I’m practicing for my exam. One of the topics covered was variable liveness.

Now, outside of a loop, if we have

1. int a = 1;
2. a++;
3. int b = 2;
4. a = b;

then variable “a” is live in 1-2 and 4, right?

Inside of a loop, if we have

1. for (int i = 1; i < 3; i++)

and then no other operations using the value of “i” inside the loop, such as checking its value and so on, then “i” is only live at the point of assignment/increment, right?

Basically the question is, for a loop such as the one mentioned above, is the control variable live within the loop or just when incrementing? Unless of course, that variable is used inside the loop.

  • 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-10T15:18:48+00:00Added an answer on June 10, 2026 at 3:18 pm

    variable “a” is live in 1-2 and 4, right?

    Yes, that is correct. Or, since we usually talk about a variable being live after or before (not during) a given step, I should say: a is live after step 1, before step 2 and after step 4 (assuming a will be used some time after those instructions).

    for a loop such as the one mentioned above, is the control variable live within the loop or just when incrementing?

    You have to think about when each step of the loop happens. The execution of a loop will look something like this:

    1. i is initialized
    2. the body executes
    3. the loop condition is checked (reading the value of i which was set in step 1)
    4. i is incremented (assuming the loop condition was true)
    5. the body excutes
    6. the loop condition is check (reading the value of i which was set in step 4)
    7. … and so on until the condition is false

    So each time after the body executes the condition is checked by reading the value of i that was set before the body was executed. This means that i has to be live during the entire execution of the body.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Did you ever have the following situation: you need to store information, but a
Did not have luck with these examples: Javascript File remove Javascript FSO DeleteFile Method
i have a parent class called Course, and two child class PostgradCourse and UndergradCourse.
I have a mex file (compiled in VS2010, Matlab 2010b) which accepts a variable,
I created a new Xcode project (iOS application, Tabbed Application). Now I'm seeing one
It seems like I should know this and I thought I did. I have
I have this ecl-make.lisp: (asdf:oos 'asdf:compile-op :stumpwm) (defun system-objects (system) (loop for component in
I have a datamodule that's used thoughout one of our line of business apps.
I am trying to compile a C program through a javacode. I did it
Did you used Dynamic websites before? you see its a good way for making

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.