I've written a program to take inputed integers from the keyboard and the use pointer to arrange the numbers in ascending and descending order without changeing the orignal entered numbers and then place into a table.
For the most part I think I have it but am getting to errors and have not been able to decipher my errors could someone please help?
I will attach code if someone is up to this challenge.
Thank you.
Code:
#include <stdio.h>
#include <stdlib.h>
#define SIZE 5
// Function Declaration
int* getData (int* pAry, int arySize);
void ascendSort (int* pAry, int* pCount);
void descendSort (int* pAry, int* pCount);
void printData (int* pAry, int* pCount);
int main (void)
{
//Local Declarations
int ary[SIZE];
int* pCount;
//Statements
pCount = getData (ary, SIZE);
ascendSort (ary, pCount);
descendSort (ary, pCount);
printData (ary, pCount);
system ("PAUSE");
return 0;
}// main
/*=============================getData=========================================
Reads data input by user from keyboard for sorting purposes.
Pre pAry is pointer to array to be filled & arySize is the last #
in array.
Post array filled. returns address of last element.
*/
int* getData(int* pAry, int arySize)
{
//Local Declarations
int ioResult;
int* pFillAry = pAry;
int elementCnt;
//Statements
printf ("Please enter 5 integers: ");
do
{
ioResult = scanf_s ("%d", pFillAry);
if (ioResult == 1)
{
pFillAry++;
elementCnt++;
}// if
} while (ioResult == 1 && elementCnt < arySize);
printf ("\n\n %d # of elements read.", elementCnt);
return (--pFillAry);
}//getData
/*============================ascendSort=======================================
Sort Array in ascending order.
Pre pointer to array
Post sorted in ascending order
*/
void ascendSort (int* pAry, int* pCount)
{
//Local Declarations
int* pIndex;
//Statements
for (pIndex = pAry; pIndex < pCount; pIndex++)
return;
}//ascendSort
/*==========================descendSort========================================
Sort Array in descending order.
Pre pointer to array
Post sorted in descending order
*/
void descendSort (int* pAry, int* pCount)
{
//Local Declarations
int* pIndex;
//Statements
for (pIndex = pAry; pIndex < pCount; pIndex++)
return;
}//descendSort
/*======================printData==============================================
Given a pointer to array. Print the data.
Pre pAry points to filled array.
pCount identifies last element in array.
Post Prints data in table form
*/
void printData (int* pAry, int* pCount)
{
//Local Declarations
int numCt;
int* pTable;
//Staements
printf ("\n\n Table \n\n");
printf("===================\n");
printf ("Asecnding Order\t Original entry\t DescendingOrder\n\n");
for (numCt = 0; numCt < 5; numCt++)
pTable[numCt] = pAry + count;
printf ("%d\t | %d\t | %d\t", ascendSort, pAry, descendSort);
return;
}//printData
//===============================End of Program================================