# C programming langue

SoccerBoss
Category:
Computer Science
Price: \$5 USD

Question description

void printarray (int a[], int size); // print out the content of array a[] with size integers

int even(int a[], int size); // return the number of even numbers in array a[]

void insert(int a[], int size, int key, int k); // insert key into array a[] so key becomes the k-th element

void second(int a[], int size); // find the second largest number in a[] and swap it // with the first element in the array

void rearrange(int a[], int size); // rearrange array a[] so all the even numbers will // have indices less than those for the odd number

Thanks,

I did the whole thing  but is not working

include <stdio.h>

void printarray (int a[],int size)

{

// print out the content of array a[] with size integers

int i;

for(i = 0; i < size; i++)

{

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

}

printf("\n");

}

int even (int a[],int size)

// return the number of even numbers in array a[]

{

int count=0;

int i;

for(i=0; i< size; i++)

{

if (a[i] % 2 == 0)

{

count++;

}

void insert(int a[], int size, int key, int k)

{

int i;

for(i=size-1;i>=k-1;i--)

a[i+1]=a[i];

a[k-1]=key;

}

void second(int a[], int size)

{

int i,largest,secondLargest,index1,index2;

for(i=0;i<size;i++)

{

if(i==0)

largest=a[i];

else if(i==1)

{

if(a[i]>largest)

{

index1=1;

index2=0;

secondLargest=largest;

largest=a[i];

}

else

{

index2=i;

index1=0;

secondLargest=a[i];

}

}

else

{

if(a[i]>largest)

{

index2=index1;

secondLargest=largest;

largest=a[i];

index1=i;

}

else if(a[i]>secondLargest)

{

index2=i;

secondLargest=a[i];

}

}

}

int temp=a[index2];

a[index2]=a[0];

a[0]=temp;

}

// find the second largest number in a[] and swap it

// with the first element in the array

void rearrange(int a[], int size)

{

int i,last=size-1;

for(i=0;i<last;i++)

{

if(a[i]%2==1)

{

while(a[last]%2!=0 &&last>=0)

{

last--;

}

if(last>=0 && last>i)

{

int temp=a[last];

a[last]=a[i];

a[i]=temp;

last--;

}

}

}

}

// rearrange array a[] so all the even numbers will

// have indices less than those for the odd number

int main(void) {

int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};

printarray (a, 12);

printf("there are %2d even numbers.\n", even(a, 12));

insert(a, 12, 20, 3);

printarray (a, 12);

insert(a, 12, 0, 0);

printarray (a, 12);

insert(a, 12, 30, 11);

printarray (a, 12);

second(a, 12);

printf("calling second(): ...\n");

printarray (a, 12);

rearrange(a, 12);

printf("calling rearrange(): ...\n");

printarray (a, 12);

return 0;

}

Studypool has helped 1,244,100 students

1824 tutors are online

### Related Computer Science questions

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors