HackerRank C- Divisible Sum Pairs

Complete the divisibleSumPairs function in the editor below. It should return the integer count of pairs meeting the criteria.

divisibleSumPairs has the following parameter(s):

n: the integer length of array ar
ar: an array of integers
k: the integer to divide the pair sum by

  1. #include<stdio.h>
  2. int main()
  3. {
  4. int n,b,k=0;
  5. scanf("%d",&n);
  6. scanf("%d",&b);
  7. int a[n];
  8. for(int i=0;i<n;i++)
  9. {
  10. cin>>a[i];
  11. }
  12. for(int i=0;i<n;i++)
  13. {
  14. for(int j=0;j<n;j++)
  15. {
  16. if(i<j&&(a[i]+a[j])%b==0)
  17. {
  18. k++;
  19. }
  20. }
  21. }
  22. printf("%d",k);
  23. }
Please click on the like button if it worked

Solution not working or have any suggestions? Please send an email to [email protected]

donate a cup of tea :)

Join Our Facebook Group

Share this solution


Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube