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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:50:35+00:00 2026-06-04T02:50:35+00:00

simple question regarding C++ code: for(int i=0;i<npts;i++) { for(int j=i;j<2*ndim;j++) { if(funcEvals[i]<bestListEval[j]) { bestListEval[j]

  • 0

simple question regarding C++ code:

for(int i=0;i<npts;i++)
{
    for(int j=i;j<2*ndim;j++)
    {
        if(funcEvals[i]<bestListEval[j])
        {
            bestListEval[j] = funcEvals[i];
            for(int k=0;k<m_ndim;k++)
                bestList[j][k] = simplex[i][k]; 
            break; 
        }
    }
}

I want to ensure that

  • Each line of double **simplex is inserted at most once in double **bestList
  • The instance of break here breaks out of the second (inner) for loop.

Is this the case?

  • 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-04T02:50:36+00:00Added an answer on June 4, 2026 at 2:50 am

    The break statement in C++ will break out of the for or switch statement in which the break is directly placed. It breaks the innermost structure (loop or switch). In this case:

        for(int i=0;i<npts;i++)
        {
            for(int j=i;j<2*ndim;j++)
            {
                if(funcEvals[i]<bestListEval[j])
                {
                    bestListEval[j] = funcEvals[i];
                    for(int k=0;k<m_ndim;k++)
                        bestList[j][k] = simplex[i][k]; 
                    break; 
                }
            }
            // after the 'break' you will end up here
        }
    

    There is no way in C++ to have break target any other loop. In order to break out of parent loops you need to use some other independent mechanism like triggering the end condition.

    Also, if you want to exit more than one inner-loop you can extract that loops into a function. In C++ 11 lambdas can be used to do it in-place – so there will be no need to use goto.

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

Sidebar

Related Questions

Hi I have question regarding cin and buffer. I want to make a simple
simple question regarding property value inheritance in UserControls. If i create a UserControl, it
I have a simple question regarding accessing member variables of a model object. I
I have a simple question regarding jQuery selectors. I'm using the tablesorter and I
Yesterday, I asked this question regarding best practices for a simple information retrieval system
I have a simple question regarding Entity declaration in JPA. I have an entity
I have a question regarding the Java Memory Model. Here is a simple class
Simple question I imagine, but what is the difference between these lines of code:
I'm back with another question regarding Android databases. I'm storing a simple string into
Okay, this is following on from my previous question reguarding performing a simple ajax

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.