3-18
You need array with the size of 16
int a[16];
a[0] indicates Number of 3 counts and
a[1] indicates Number of 4 counts and
....
a[15] indicates Number of 18 counts.
You need to change this for loop
for(i = 0; i <= 15; i++)
a[i] = 0;
and this statement
a[d1 + d2+d3] = a[d1 + d2 + d3] + 1;
Modify like this
++a[d1 + d2 + d3 - 3];
And final for loop also, you need two loops.
for(i = 0; i <= 15; i = i + 1)
{
printf("%3d - ", i+3);
for(j=0;j<a[i];j++)
{
printf("%c ",'*');
}
printf("\n");
}