repl.it
@manoj2rox/

dailyprog1InC-1

C

No description

fork
loading
Files
  • main.c
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>

int main(void) {
  int n;
  printf("enter array size :: ");
  scanf("%d",&n);
  int a[n];
  for(int i = 0; i < n; i++ ) {
    scanf("%d", &a[i]);
  }

  int k;
  printf("enter k value :: ");
  scanf("%d", &k);
  int count = 1;
  int temp;

  for( int i = 0; i < n - 1; i++) {
    for( int j = count; j < n; j++) {
      temp = a[i] + a[j];
      if( temp == k ) {
        printf("%d + %d is %d\n",a[i],a[j],temp);
      }
    }
    count++;
  }
  return 0;
}
?