Permalink
Browse files

Sum of Pairs: C solutions by Hardy Jonck

  • Loading branch information...
1 parent d759fd6 commit 5fafbd73d9159ebf148d4505fda234e4a6bee2e5 @apauley committed Sep 18, 2009
Showing with 3 additions and 1 deletion.
  1. +3 −1 CodeSnippets/SumPairs/sumpairs.c
View
4 CodeSnippets/SumPairs/sumpairs.c
@@ -4,7 +4,9 @@
int main (int argc, const char * argv[]) {
int a[] = {1,2,3,4,5};
+ int b[sizeof(a)/sizeof(int)-1];
char x;
- for (x=0; x<sizeof(a)/sizeof(int)-1; x++) { a[x] += a[x+1];printf("%d,",a[x]);}
+ for (x=0; x<sizeof(a)/sizeof(int)-1; x++) { b[x] = a[x]+ a[x+1];printf("%d,",b[x]);}
+
return 0;
}

0 comments on commit 5fafbd7

Please sign in to comment.