I need to make this work without global varibles! Can someone please HELP!
thank you and i appreciate your helpCode://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; }
Code tags fixed by Hammer



LinkBack URL
About LinkBacks


