Sunday 24 February 2019

Filled Under:

Generating Numbers in the Combination of given Numbers[c programming examples with output]

Generating Numbers in the Combination of given Numbers

Program:

#include<stdio.h>
#inclue<conio.h>
main()
{
        int t,r,range,i,j,s,d;
        int a[5],b[5];
        long n;
        clrscr();
        printf("Enter no. of numbers for combination : ");
        scanf("%d",&d);
        printf("\nENter numbers for combination : ");
        for(i=0;i<d;i++)
           scanf("%d",&a[i]);
           printf("\nEnter the range : ");
           scanf("%d",&range);
           for(i=1;i<=range;i++)
          {
               n=i;s=0;t=0;
               while(n>0)
               {
                   j=0;
                   r=n%10;
                   t++;
                   while(j<d)
                   {
                       if(r==a[j])
                       s++;
                       j++;
          }
          n=n/10;
  }
         if(s==t)
             printf("%d\t",i);
         }
  getch();
}

OutPut:

Enter no. of numbers for combination:2
Enter numbers for combination:4
8
Enter the range:500
4    8    44    48    84    88
444  448  484   488

                                        Best Budget Laptop For Web Developers 2019
Best Budget Laptop For Programmershttps://amzn.to/2LOr3w9

0 komentar:

Post a Comment