# I haev to make this work!

• 11-04-2002
SledMan2002
I haev to make this work!

Code:

``` //David Thurlby //CIS 150 //Assignment 6-7 #include <stdio.h> #include <time.h> #include <stdlib.h> #include <conio.h> #define SIZE 20 int getRand(); int sortA(); int sortD(); int printSorted(); int main() {         //declared         int a[SIZE];         int b[SIZE];         int count;//in functions         int swap1,swap2;//in main           printf("Getting Random Numbers\n");         getRand();         for(count=0;count<SIZE;count++)     printf("%4d",a[count]);           sortA(a[SIZE]);         sortD(b[SIZE]);           printf("\n\n");         printf("Swaps for A= %d\n",swap1);         printf("Swaps for D= %d\n",swap2);         printf("Press Any Key To Continue");         getch();         system("cls");         printSorted();         return 0; } int getRand(a[SIZE],count)//getting Random num {            srand(time(NULL));     for(count=0;count<=SIZE;count++)   {     a[count]=b[count]=rand()%100;   }          return 0; } int sortA(a[SIZE],count,swap1)//sort Acending {   for(swap1=1;swap1<=SIZE-1;swap1++)   {     for(count=0;count<=SIZE-2;count++)     {       if(a[count]>a[count+1])       {         hold = a[count];         a[count]=a[count+1];         a[count+1] = hold;       }     }   }   return 0;        } int sortD(b[SIZE],count,hold,swap2)//sort Descending {   for(swap1=1;swap1<=SIZE-1;swap1++)   {     for(count=0;count<=SIZE-2;count++)     {       if(b[count]<b[count+1])       {         hold = b[count];         b[count]=b[count+1];         b[count+1] = hold;       }     }   }   return 0;        } int printSorted(a[SIZE],b[SIZE],count)//printing {   for(count=0;count<SIZE;count++)     printf("%d\n",a[count]);   getch();   system("cls");   for(count=0;count<SIZE;count++)     printf("%d\n",b[count]);     return 0; }```
thank you and i appreciate your help

Code tags fixed by Hammer
• 11-04-2002
Magos
Eh? What global variables?

And the end-code-tag is [/code], not [end code].
• 11-04-2002
SledMan2002
I cant get this to work!
I had global varibles in this and i took them out and stuck them into main. It says i have 12 errors in it for some reason and i dont get why. Can you help?

Code:

```//David Thurlby //CIS 150 //Assignment 6-7 #include <stdio.h> #include <time.h> #include <stdlib.h> #include <conio.h> #define SIZE 20 int getRand(); int sortA(); int sortD(); int printSorted(); int main() {         //declared         int a[SIZE];         int b[SIZE];         int count;//in functions         int swap1,swap2;//in main           printf("Getting Random Numbers\n");         getRand();         for(count=0;count<SIZE;count++)     printf("%4d",a[count]);           sortA(a[SIZE]);         sortD(b[SIZE]);           printf("\n\n");         printf("Swaps for A= %d\n",swap1);         printf("Swaps for D= %d\n",swap2);         printf("Press Any Key To Continue");         getch();         system("cls");         printSorted();         return 0; } int getRand(a[SIZE],count)//getting Random num {            srand(time(NULL));     for(count=0;count<=SIZE;count++)   {     a[count]=b[count]=rand()%100;   }          return 0; } int sortA(a[SIZE],count,swap1)//sort Acending {   for(swap1=1;swap1<=SIZE-1;swap1++)   {     for(count=0;count<=SIZE-2;count++)     {       if(a[count]>a[count+1])       {         hold = a[count];         a[count]=a[count+1];         a[count+1] = hold;       }     }   }   return 0;        } int sortD(b[SIZE],count,hold,swap2)//sort Descending {   for(swap1=1;swap1<=SIZE-1;swap1++)   {     for(count=0;count<=SIZE-2;count++)     {       if(b[count]<b[count+1])       {         hold = b[count];         b[count]=b[count+1];         b[count+1] = hold;       }     }   }   return 0;        } int printSorted(a[SIZE],b[SIZE],count)//printing {   for(count=0;count<SIZE;count++)     printf("%d\n",a[count]);   getch();   system("cls");   for(count=0;count<SIZE;count++)     printf("%d\n",b[count]);     return 0; }```
• 11-04-2002
SledMan2002
THANX!
Thanx man, i totally appreciate it. Ive been workin on this stuff and i jus dont get what im doin. Ya helped me alot.