Hi,

May this s not an optimised/generalise solution ..But it produces the output as expected
The code snippet is as under:

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

                for ( l=k+1;l<10;l++)
                {
                    sum = i+j+k+l ;
                        if(sum == 10)
                        {
                        printf("%d %d %d %d \n",i,j,k,l);
                        break;
                        }

                }

         }
    }
  }

Last edited by shabbir; 20Jun2011 at 17:16.. Reason: Code blocks