Answers for "How to find all pairs on integer array whose sum is equal to given number?"

C
0

find the numbers of pairs whose sum is 10 in c array

#include <stdio.h>
void main ()
{
    int a[10];
    int i,j;

    for (i=0;i<10;i++)
    {
        printf("Enter %d number: ",i+1);
        scanf("%d",&a[i]);
    }

    int count=0;

    for (i = 0; i < 10; ++i)
    {
        for(j=i+1;j<10;j++)
        {
            if (a[i] + a[j] == 10)
                count++;
        }
    }

    printf("The number of pairs that have sum of 10 is %d",count);
}
Posted by: Guest on June-25-2021

Code answers related to "How to find all pairs on integer array whose sum is equal to given number?"

Code answers related to "C"

Browse Popular Code Answers by Language