edited by
289 views
0 votes
0 votes

Consider the following program, what will be the output -?

#include<stdio.h>
int main()
{
    int a[m][n]={{1,2,3},{4,5,6}};
    int i,j;
    for(i=0;i<m;i++)
    {
        for(j=0;j<n;j++)
        {
            printf("%d ",*(a[j]+i));
        }
    }
    return 0;
}
edited by

2 Answers

0 votes
0 votes
i am assuming  the value of m,n be 3,3 respectively

so output for the program is 140250360

int main()
{
    int a[3][3]={{1,2,3},{4,5,6}};
    int i,j;
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            printf("%d ",*(a[j]+i));
        }
    }
    return 0;
}

Related questions

0 votes
0 votes
0 answers
1
sadiashafaque asked Aug 6, 2018
340 views
What is the output of this code in c?int main(){static int a[] [3]={0,1,2,3,4,5,6,7,8,9,10,11,12};int i=-1;int d;d=a[i++][++i][++i]; printf("%d",d); return 0;} how did 2 ...
6 votes
6 votes
1 answer
4