combinations of I, J, K and L, such that :I + J + K = L and I < J < K < L. I, J, K and L be positive integers from 1 to 15



Let I, J, K and L be positive integers from 1 to 15. Write a program that finds and prints all
combinations of I, J, K and L, such that :
                                                           I + J + K = L and I < J < K < L.

Program:

#include<stdio.h>
int main()
{
      int i,j,k,l;
      for(l=1;l<=15;l++)
      for(k=1;k<l;k++)
      for(j=1;j<k;j++)
      for(i=1;i<j;i++)
      {
            if((i+j+k)==l)
            printf("%d+%d+%d=%d \n",i,j,k,l);
       }
       return 0;
}

Output:

1+2+3=6
1+2+4=7
1+3+4=8
1+2+5=8
2+3+4=9
1+3+5=9
1+2+6=9
2+3+5=10
1+4+5=10
1+3+6=10
1+2+7=10
2+4+5=11
2+3+6=11
1+4+6=11
1+3+7=11
1+2+8=11
3+4+5=12
2+4+6=12
1+5+6=12
2+3+7=12
1+4+7=12
1+3+8=12
1+2+9=12
3+4+6=13
2+5+6=13
2+4+7=13
1+5+7=13
2+3+8=13
1+4+8=13
1+3+9=13
1+2+10=13
3+5+6=14
3+4+7=14
2+5+7=14
1+6+7=14
2+4+8=14
1+5+8=14
2+3+9=14
1+4+9=14
1+3+10=14
1+2+11=14
4+5+6=15
3+5+7=15
2+6+7=15
3+4+8=15
2+5+8=15
1+6+8=15
2+4+9=15
1+5+9=15
2+3+10=15
1+4+10=15
1+3+11=15
1+2+12=15
 

No comments: