I'm pretty much new to pointers and function. Yes this an assignment, but i just want to know if I'm going in the right direction. Any comments is greatly appreciated.
#include <iostream>
usingnamespace std;
int BubSort(int *,int i); // You needed a semi-colon here
int main()
{
int p, i,sort; // avg is not required
int *pter;
cout<<"Enter how many grades you want to enter: ";
cin>>i;
pter= newint[i]; //You need to make this an array of ints, not pter
for(p=0;p<i;p++)
{
cout<<"\n Enter grade: ";
cin>>pter[p];
}
sort=BubSort(pter, i); // You need to put arguments in here, Bubsort should be BubSort
cout<<"Grades are: "<<sort<<endl;
delete pter; // You spelled delete wrong, you also need to specify the object to delete.
}
int BubeSort(int *pter, int i) // Should be int, not float
{ int a,b,temp; //should be ints
for(a=0;a<i;a++)
{
for(b=i-1;b>=a;b--)
{
if(*(pter-1)<*pter)
temp=*(pter-1);
*(pter-1)=*pter;
*pter=temp;
}
}
return *pter;
}