Sunday 24 February 2019

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

Friday 8 February 2019

Program To Find The Sum Of The Given n Integers Using An Array[c programming examples with output]

Write A Program To Find The Sum Of The Given n Integers Using An Array

/*Program To Find Sum Of n Integers*/
#include<stdio.h>
#include<conio.h>
main()
{
    int x[50],n,i,sum;
    clrscr();
    printf("\n How many integers??");
    scanf("%d",&n);
        /*loop to read N integers*/
         f or(i=0;i<n;i++)
   {
       printf("\n Enter the %dth value: ",i+1);
       scanf("%d",&x[i]);
   }
   sum=0;
      /*loop to find sum of all integers*/
         for(i=0;i<n;i++)
       sum=sum=sum+x[i];
       printf("\nSum of all integers=%d",sum);
       getch();
}

OutPut:
How many integers??5
Enter the 1th value: 36
Enter the 2th value: 45
Enter the 3th value: 52
Enter the 4th value: 40
Enter the 5th value: 61
Sum of all integers=234

                                                   
                                         Best Budget Laptop For Web Developers 2019
Best Budget For Programmers: https://amzn.to/32GkrqC