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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:33:43+00:00 2026-05-26T13:33:43+00:00

I have small issue. I create 2D int array. When I cout it I

  • 0

I have small issue. I create 2D int array. When I cout it I get hexadecimals numbers insted of decimals. I’m using Dev C++.

#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
    const int max=9;
    int ar[max][max]={
        {0,6,0,0,2,0,0,4,0},
        {5,0,0,3,0,0,0,0,0},
        {0,8,0,0,1,0,0,0,0},
        {6,0,0,0,0,7,0,0,0},
        {0,3,7,0,0,0,2,8,0},
        {0,2,0,8,0,0,0,3,0},
        {0,0,0,0,0,0,0,0,0},
        {7,0,0,4,0,0,0,0,1},
        {0,0,0,0,6,0,0,2,0}};

    for (int i=0;i<max;i++){
        for(int j=0;j<max;j++){
            cout<<ar[i,j]<<" ";
        }
        cout<<"\n";
    }

    system("pause");
    return 0;
}

In return I get this http://www.dropmocks.com/mf8wl

  • 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-26T13:33:44+00:00Added an answer on May 26, 2026 at 1:33 pm

    That’s because you’ve fallen into the cunning trap of operator ,!

    First of all, C doesn’t have multi-dimensional arrays as a primitive. As you’ve declared here, a 2D array is just “an array of arrays”. Therefore, it makes no sense to access an array with a[i,j]. You should first get the “row” with a[i] then index the “column” with [j], whence a[i][j].

    So, why does your code compile? Because the , is an operator in C. The evaluation of a,b is effectively the evaluation of expression a, then b, returning the result of evaluating b. Hence you’re actually printing a[j] here, which is an int[], printed in hex as the address of the array.

    Why have an operator , at all, you ask? Other than to be confusing, it’s mostly for constructs like for, where you might want multiple expressions in an initialiser or incrementation construct, i.e. for (j = 0, i = 0; i + j < k; i++, j += 2) or similar.

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

Sidebar

Related Questions

MSSQL database. I have issue to create database using old databases data. Old database
I am just new to programming in Unix and have a small issue that
can anyone help, i have a small issue, i have an interface and also
We're having a small issue and could use some help - we have the
everything is working fine with my jqgrid except a small issue. i have defined
I have small database of business and their addresses. Using the Google Geocode API
am trying to get my head around the following: Have a small program am
I have the following issue whith this very simple task. I want to create
I have a small program where I have been trying to create collections of
I am working on an Android opengl lib and have hit a small issue.

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.