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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:14:06+00:00 2026-05-30T12:14:06+00:00

Possible Duplicate: C++ Comma Operator I am initializing an array with int main() {

  • 0

Possible Duplicate:
C++ Comma Operator

I am initializing an array with

int main()
{
    int arr[3]= { (1,3), 2, 4 };
    cout << arr[0] << " " << arr[1] << " " << arr[2] << endl;
}

I thought it would give a compile time error but it is running fine. The array is initialized with values 3,2,4 and output is also 3 2 4.

Can someone explain what is happening here ?

  • 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-30T12:14:07+00:00Added an answer on May 30, 2026 at 12:14 pm

    You’re looking at the comma operator there. Basically, the expression:

    1,7
    

    will evaluate 1 but “return” 7.

    That particular form you have (as well as mine above) is not that useful but you can do things like:

    x = a++, 1;
    

    to both increment a and set x to 1 (the usefulness comes from side effects).

    You will have seen this before without necessarily realising it:

    for (i = 0, j = 0; i < 4; i++, j++) ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: C++ Comma Operator what is result of operator ',' by standard? Last
Possible Duplicate: How to create comma separated list from array in PHP? I have
Possible Duplicate: C++ Comma Operator that probably a trivial question, but I don't know
Possible Duplicate: The most sophisticated way for creating comma-separated Strings from a Collection/Array/List? I
Possible Duplicate: C++ Comma Operator About a year ago I noted some obscure syntax
Possible Duplicate: SQL Server: Can I Comma Delimit Multiple Rows Into One Column? I
Possible Duplicate: How do I Create a Comma-Separated List using a SQL Query? I
Possible Duplicate: How can I combine multiple rows into a comma-delimited list in Oracle?
Possible Duplicate: Combine multiple results in a subquery into a single comma-separated value Concat
Possible Duplicate: array_splice() for associative arrays How to add an array value to the

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.