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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:28:56+00:00 2026-06-06T21:28:56+00:00

for(int a = 0, b = 1; b < n; a++; b++) { if

  • 0
    for(int a = 0, b = 1; b < n; a++; b++)
    {
        if (compare(values[a], values[b]))
            counter++;
        else
            {
            int x = values[a];
            values[a] = values[b];
            values[b] = x;
            }
    }

I get this error for the first line [ for(int… ] when I try to compile:

helpers.c:68:41: error: expected ')' before ';' token

Why would I need to add another ‘)’?

  • 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-06T21:28:59+00:00Added an answer on June 6, 2026 at 9:28 pm
    for(int a = 0, b = 1; b < n; a++; b++)
                                    ^
                                    |
                                  problem
    

    You need a comma (,) rather than a semicolon (;) at the end of your for-loop where you increment both a and b:

    for(int a = 0, b = 1; b < n; a++, b++)
                                    ^
    

    This is the comma operator.

    These two SO questions might also be helpful: How do I put two increment statements in a C++ 'for' loop?
    and What is the full "for" loop syntax in C (and others in case they are compatible)?

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

Sidebar

Related Questions

With regards this example from Code Complete: Comparison Compare(int value1, int value2) { if
I would like to know how to compare int values. I would like to
I need to compare a int value with a datetime in a SQLExpress table.
fringe = new PriorityQueue<Node>(10,new Comparator<Node>(){ @Override public int compare(Node node1,Node node2) { if (f(node1)>f(node2))
When I compare strings containing positive/negative numbers, for example: int res1 = -1.CompareTo(1); int
int a[2]; This in memory actually looks like: //Assuming int is 2 bytes add=2000,
I'm want a IDictionary<float, foo> that returns the larges values of the key first.
My goal is to load values in a 5x5 matrix and compare each value
public final Comparator<String> ID_IGN_CASE_COMP = new Comparator<String>() { public int compare(String s1, String s2)
I often get into situation when I need to sort a Map on values.

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.