can you explain below program

#include <stdio.h>
void main()
{
int a[5]={5,1,10,15,20};
int i,j,m;

i=++a[1];
j=a[i]++;
m=a[i++];
printf("%d,%d,%d",i,j,m);

}

Right, you are given an array arr[] = {5,1,10,15,20}

Let’ go step-by-step,

Step 1: i = ++a[1];
What is a[1] ?, a[1] = 1, but with a pre-increment operator, a[1] becomes 2, and hence i. --> i = 2

Step 2: j = a[i]++, mind the post-increment operator, j = a[i (==2)] = a[2] = 10. Also a[2] = a[2] + 1 = 11 --> j = 10

Step 3 : m = a[i++], again post-increment, i.e. m = a[2] and i = i + 1 --> m = 11 and i = 3

Hence (i,j,m) = (3,10,11) :slight_smile: