fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int arr[8]={1,2,3,4,5,6,7,8};
  5. int x=10;
  6. int count=0;
  7.  
  8. for(int i=0;i<8;i++){
  9. for(int j=i+1;j<8;j++){
  10. for(int k=j+1;k<8;k++){
  11.  
  12. if( arr[i]+arr[j]+arr[k]==x) count++;
  13. else continue;
  14. }
  15. }
  16. }
  17. printf("The no. of pairs are:%d",count);
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
The no. of pairs are:4