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. if( i+j==x) count++;
  11. else continue;
  12. }
  13. }
  14. printf("The no. of pairs are:%d",count);
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0.01s 5296KB
stdin
Standard input is empty
stdout
The no. of pairs are:2