Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdint.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- void main(){
- int16_t *arr;
- long long int sum = 0, size = 500000000, count = 0;
- srand(1);
- arr = (int16_t*) calloc(size, sizeof(int16_t));
- for(count = 0; count < size; count++){
- arr[count] = (rand() % 65537) - 32769;
- }
- clock_t begin = clock();
- for(count = 0; count < size; count++){
- arr[count] *= 0.75;
- }
- clock_t end = clock();
- double time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
- for(count = 0; count < size; count++){
- sum += arr[count];
- }
- printf("sum is %d\n", sum);
- printf("time taken for part b was %lf\n", time_spent);
- free(arr);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement