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 5949837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:18:27+00:00 2026-05-22T17:18:27+00:00

this is probably a very noob question but I was what the result of

  • 0

this is probably a very noob question but I was what the result of this would be:

int someVariable = 1;

while (callFunction(someVariable));

    if (someVariable = 1) {
        printf("a1");
    } else {
        printf("a2");
    }

callFunction (int i) {
    while (i< 100000000) {
        i++;
    }
    return 0;
}

so when you hit the while loop

while (callFunction(someVariable));

does a thread wait at that loop until it finishes and then to

if(someVariable == 1) {
    printf("a1");
} else {
    printf("a2");
}

or does it skip and move to the if condition, print “a2” and then after the loop has finished goes through the if condition again?

UPDATE: This isn’t ment to be valid c code just psuedo, maybe I didn’t word it right, basically what I’m trying to figure out is what the different between a loop like while (callFunction(someVariable)); is vs

while (callFunction(someVariable)){}

i also changed the bolded part in my code i.e ** int someVariable = 1; **, I was doing an endless loop which wasn’t my intention.

  • 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-05-22T17:18:28+00:00Added an answer on May 22, 2026 at 5:18 pm

    UPDATE

    basically what I’m trying to figure out is what the different between a loop like while (callFunction(someVariable)); is vs while (callFunction(someVariable)){}

    No practical difference. ; delimits an empty statement, { } is a scope without statements. Any compiler can be expected to produce identical code.

    Of course, if you want to do something in each iteration of the loop, { } creates a “scope” in which you can create types, typedefs and variables as well as call functions: on reaching the ‘}’ or having an uncaught exception, the local content is cleaned up – with destructors called and any identifiers/symbols use forgotten as the compiler continues….

    ORIGINAL ANSWER

    This…

    callFunction(int i){
         while (i< 100000000){
             i++;
         }
         return 1;
    }
    

    …just wastes a lot of CPU time, if the compiler’s optimiser doesn’t remove the loop on the basis that it does no externally-visible work – i.e. that there are no side-effects of the loop on the state of anything other that “i” and that that’s irrelevant because the function returns without using i again. If always returns “1”, which means the calling code…

    while (callFunction(someVariable)); 
    

    …is equivalent to…

    while (1)
        ;
    

    …which simply loops forever.

    Consequently, the rest of the program – after this while loop – is never executed.

    It’s very hard to guess what you were really trying to do.

    To get better at programming yourself – understanding the behaviour of your code – you should probably do one or both of:

    • insert output statements into your program so you can see how the value of variables is changing as the program executes, and whether it’s exiting loops
    • use a debugger to do the same
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sorry for this ( probably very ) noob question, but i've been asked
This is probably a very simple question so please forgive my ignorance, but can
This is probably a very simple question but I'm a little confused how this
I understand that this is a probably a noob-ish question, but I've had no
This is probably very straight forward and simple, but I'm very new and noob
This is a very simple, probably too simple question but I'm afraid my limited
This is probably a bit of a noob question but seeing as I am
This is a very quick (and probably noob) question. I am creating a dependencyobject
This is probably very simple, but i've been stuck for a while. I have
This is probably very stupid question but here we go class Foo < ActiveRecord::Base

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.