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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:05:00+00:00 2026-05-26T18:05:00+00:00

Is there a way to bulk evaluate the contents of an array in C++?

  • 0

Is there a way to “bulk evaluate” the contents of an array in C++? For example, let int numbers[10]={23,42,12,42,53,10,0,0,0,0}. Is there a way to loop through each element in the array and check whether the element meets a specified condition?

In short, I’d like to be able to do something like:

if(every element in the array meets arbitrary condition)
do this

or

if(array element from m to array element n==something)
do this

For small arrays, I know I could use something like: if(numbers[0]==blabla) && if(numbers[n]==blabla), then do this, but obviously this is not a realistic solution when it comes to evaluating very large arrays.

  • 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-26T18:05:01+00:00Added an answer on May 26, 2026 at 6:05 pm

    ” if(every element in the array meets arbitrary condition) do this ”
    with STL:

    bool IsOdd (int i) 
    {
      return ((i%2)==1);
    }
      //...
    {
      vector<int> myvector;
      vector<int>::iterator it;
    
      myvector.push_back(2);
      myvector.push_back(4);
      myvector.push_back(6);
      myvector.push_back(8);
    
      it = find_if (myvector.begin(), myvector.end(), IsOdd);
      if (it == myvector.end())
        cout<< "No Odd numbers";
      }
    

    ” if(every element in the array meets arbitrary condition) do this ”
    without STL

    numbers[10]={2,4,6,8,10,12,14,16,18,20}
    bool oddExist=false;
    for (int i =0;i<10;++i)
      {
         if ( numbers[i]%2 )
         {                      //added
           oddExist=true;     
           break;               //added  for efficiency, was not in 
         }                      //        first post. 
      }
          if (!oddExist)
            cout<< "No Odd numbers";
    

    “if(array element from m to array element n==something) do this”
    with STL

    void printNumber (int i) 
    {
      cout  << i;
    }
    
      // ... 
    
      vector<int> myvector;
      myvector.push_back(10);
      myvector.push_back(20);
      myvector.push_back(30);
      myvector.push_back(40);
    
      for_each (myvector.begin(), myvector.end(), printNumber);
    

    “if(array element from m to array element n==something) do this”
    without STL

    numbers[10]={2,4,6,8,10,12,14,16,18,20}
    
    for (int i =0;i<10;++i)
       cout << numbers[i];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A colleague tells me that there is no way to bulk insert UTF-8 encoded
Is there any way to speed up bulk inserting in 2005? I'm looking into
Is there any way to bulk-export Microsoft Access code to files? I see I
Via the Lighthouse user interface, is there any way to bulk stop watching tickets?
Is there a way to do a bulk insert in Sql Server where rows
is there any way to insert in bulk (i mean all gridview rows) to
Is there a way in Java to write to disk a large array of,
Is there any way of performing in bulk a query like INSERT OR UPDATE
Is there a cheap way to import bulk data into app engine without paying
Is there a way to upload database contents to Google App Engine for Java,

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.