Question: //Error message: [Error] expected declaration specifiers or '...' before 'time' //My exact code is pasted below. I cant figure out why srand isnt working. Ignore

//Error message: "[Error] expected declaration specifiers or '...' before 'time'"

//My exact code is pasted below. I cant figure out why srand isnt working. Ignore what ive commented out as I havent started working on that yet.

#include "stdio.h"

#include "time.h"

#include "stdlib.h"

#define N 10

void print_array2(double array[], int length);

//void bubble_sort(double array[], int length, in order);

//void insertion_sort(double array[], int length);

int i;

srand(time(0));

void main(){

double array1[N];

double array2[N];

double array3[N];

for(i=0; i

array1[i] = rand() % 200 - 100;

array2[i] = rand() % 200 - 100;

array3[i] = rand() % 200 - 100;

}

print_array2(array1,N);

print_array2(array2,N);

print_array2(array3,N);

/*

bubble_sort(array1,N,0);

bubble_sort(array2,N,1);

insertion_sort(array3,N);

print_array2(array1,N);

print_array2(array2,N);

print_array2(array3,N);

*/

}

void print_array2(double array[], int length){

for(i=0; i

printf("%d ", array[i]);

}

printf(" ");

}

//Error message: "[Error] expected declaration specifiers or '...' before 'time'" //My exact

CAUserslmjord\Desktop\C Homeworkic files\hw4_4.c - Dev-C+5.11 File Edit Search View Project Execute Tools AStyle Window Help Project Classes Debug globals) hw4 4.c 1 *3) Write a program that declares three arrays with N elements with random values between -100 to 100 2 3 4 I) rite a print_array2 function that prints the entires in an array of type double 5 6 7 8 VI) Compare the runtime of the bubble sort and the insertion sort functions (no submission required). 9 Use cr#define N 10" to set N to an arbitrary number before the main function. The define statement, the function prototypes, and the sample main function are provided below II) Write a bubble sort function that sorts the elements in ascending or descending order depending on the value of the input argument order (0-ascending and 1-descending) III) Write an insertion sort function that sorts that numbers in an array in ascending order. 10 #include "stdio.h" 11 #include "time.h" 12 #include "stdlib.h" 13 #define N10 14 15 void print_array2 (double array[], int length) 16 //void bubble-sort(double array[], nt Length, in order); 17 //void insertion_sort(double arrayl], int length) 18 int i; srand(dtime (e)); void main(){ 20 21 double array1[N]; double array2[N]; double array3[N]; for (i=0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!