Skip to content

Instantly share code, notes, and snippets.

@certik
Created September 9, 2011 06:34
Show Gist options
  • Select an option

  • Save certik/1205624 to your computer and use it in GitHub Desktop.

Select an option

Save certik/1205624 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
int * bill2(int n) {
int * a = malloc(sizeof(int)*n);
int i;
for (i = 0; i < n; i++)
a[i] = i;
return a;
}
long bill(int * a, int n) {
long s = 0;
int i;
for (i = 0; i < n; i++)
s += a[i];
return s;
}
int main(void)
{
int * a = bill2(100000000);
printf("%ld\n", bill(a, 100000000));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment