Given an array a[] and a number b, check for pair in a[] with sum as b

Given an array a[] and a number b, check for pair in a[] with sum as b
Write a C program that, given an array a[] of n numbers and another number b, determines whether or not there exist two elements in a[] whose sum is exactly b

#include<stdio.h>

main()
{

 int a[20],i,j,sum,n,b;

  printf("Enter Number b:\n");
  scanf("%d",&b);

  printf("Enter Number Of Element in Array:\n");
  scanf("%d",&n);

  printf("Read Array Element From User:");
   for(i=0;i<n;i++)
    {
      scanf("%d",&a[i]);
    }

    for(i=0;i<n-1;i++)
     {
      for(j=i+1;j<n;j++)
       {
         sum=a[i]+a[j];
         if(sum==b)
         printf("Sum of Pair a[%d] & a[%d] equal to b=%d\n",i,j,b);
       }
   }
}
Copyright © C Program | Java | OpenGL Programming | Hadoop at Computaholics