oaky i got it down to 2 errors HELP!!!


g labs\lab6.exe" -g3 -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -g3
C:\Users\Glenda hayes\Documents\c++ programing labs\lab6.cpp: In function `void sortArray(float*, int)':
C:\Users\Glenda hayes\Documents\c++ programing labs\lab6.cpp:56: error: overloaded function with no contextual type information
C:\Users\Glenda hayes\Documents\c++ programing labs\lab6.cpp:56: error: invalid operands of types `<unknown type>' and `int' to binary `operator>'
C:\Users\Glenda hayes\Documents\c++ programing labs\lab6.cpp:56: error: no post-increment operator for type

C:\Users\Glenda hayes\Documents\c++ programing labs\lab6.cpp: At global scope:

C:\Users\Glenda hayes\Documents\c++ programing labs\lab6.cpp:70: error: expected declaration before '}' token

Execution terminated


------------------------------

#include <iostream>
#include <fstream>
using namespace std;

//this program is going to output the student id and gpa in accending order
//function prototype
void sortArray(float,int);

int main()
{
const int SIZE= 100; //Array size
int id[SIZE];
int GPA;
int j;

ifstream inputFile;
char dataFile[20];

inputFile.open("dataFile.txt");

char fileName[20];
cout<<" The file name is GPA.txt";
ofstream outputFile;
outputFile.open("GPA.txt");
cout<<id<<endl;
cout<<GPA<<endl;
for(j = 0; j< SIZE; j++)
{
cout<<"please enter the student id number"<<endl;
cin>>id[j];
cout<<"please enter the gpa. "<<endl;
while(GPA!=99)
{
cout<<"please enter the gpa. ";
cin>>GPA;
cout<<GPA;
}
sortArray(GPA, SIZE);
inputFile.close();
outputFile.close();
system("pause");
return 0;
}


void sortArray (float GPA[],int SIZE)

{

bool swap;
float GPA;

do
{
swap=false;
for(count=0; count>(SIZE-1); count++)
{
if(array[SIZE]> array[SIZE + 1])
{
GPA=array[SIZE];
array[SIZE]=array[SIZE + 1];
array[SIZE + 1] = GPA;
swap = true;
}
}
} while (swap);
{

}
cout<<GPA<<endl;
}
}

Last edited on
At least your function declaration

void sortArray(float,int);


does not correspond to the function definition

void sortArray (float GPA[],int SIZE)


i changed taht to array

this is all i have left on the errors
70 C:\Users\Glenda hayes\Documents\c++ programing labs\lab6.cpp expected declaration before '}' token
Hear

1
2
cout<<id<<endl;
cout<<GPA<<endl;


you 1) are incorrectly trying to display an array 2) that with variable GPA were not initialized.

And here

1
2
3
4
5
for(j = 0; j< SIZE; j++)
 {
 cout<<"please enter the student id number"<<endl;
 cin>>id[j];
 cout<<"please enter the gpa. "<<endl;


you forgot "}" at the end of the code block.
Last edited on
When you use a {, indent your code. This will enable you to see when you have missed a closing }, as in the code below, which is your code, but indented to enable you to see the missing }.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
int main()
{
  const int SIZE= 100; //Array size
  int id[SIZE];
  int GPA;
  int j;
  
  ifstream inputFile; 
  char dataFile[20];
  
  inputFile.open("dataFile.txt"); 
  
  char fileName[20];
  cout<<" The file name is GPA.txt";
  ofstream outputFile;
  outputFile.open("GPA.txt");
  cout<<id<<endl;
  cout<<GPA<<endl;
  for(j = 0; j< SIZE; j++)
  {
    cout<<"please enter the student id number"<<endl;
    cin>>id[j];
    cout<<"please enter the gpa. "<<endl;
    while(GPA!=99)
    {
      cout<<"please enter the gpa. ";
      cin>>GPA;
      cout<<GPA;
    }

  sortArray(GPA, SIZE);
  inputFile.close();
  outputFile.close();
  system("pause");
  return 0;
}

ompiler: Default compiler
Executing g++.exe...
g++.exe "C:\Users\Glenda hayes\Documents\c++ programing labs\lab6.cpp" -o "C:\Users\Glenda hayes\Documents\c++ programing labs\lab6.exe" -g3 -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -g3
C:\Users\GLENDA~1\AppData\Local\Temp/cc4Gcaaa.o(.text+0x34d): In function `main':
C:/Users/Glenda hayes/Documents/c++ programing labs/lab6.cpp:38: undefined reference to `sortArray(float, int)'
collect2: ld returned 1 exit status

Execution terminated

okay what about now.
You call function

sortArray(GPA, SIZE);
with the scalar value GPA instead of an array. GPA was declared a s a scalar type.
it did it with me having it as an array.
Here is you declaration.

int GPA;

si I do not see that GPA is an array.
Topic archived. No new replies allowed.