15,665,444 members
0.00/5 (No votes)
See more:
```#include <iostream>
using namespace std;
int minimum (double grades [], int N)
{
double ans = 101;
for ( int i = 0; i< N; i++)
if (grades [i] < ans)
ans = grades [i];
return ans;
}

int maximum (double grades [], int N)
{
double ans = -1;
for (int i=0 ; i<N ; i++)
if (grades [i] > ans)
ans = grades [i];
return ans;
}

{
double min_value;
int min_index;
double temp;
for (int i =0; i<npts -1 ; i++)
{
min_value = x[i];
min_index = i;
for (int j=i+1; j<npts; j++)
{
if (x[j] < min_value)
{
min_value = x[j];
min_index = j;
}
}
temp = x[min_index];
x[min_index]= x[i];
x[i] = temp;
}
return;
}

int main ()
{
int N;
double grades [100];
cout << "Enter the number of students" << endl;
cin >> N;
int i = 0;
double value;
while (i<N)
{
com >> value;
if (value >= 0 && value <=100)
{
grades [i] = value;
i++;
}
else
{
cout << "Invalid grade. ReEnter" <<endl;
}
}
cout <<"Maximum grade is = "<< maximum (grades,N) <<endl;
cout << "Minimum grade is= " << minimum (grades,N) <<endl;
cout << "Avergage grade is= "<< average (grades,N) <<endl;
cout << "Numbers of the students above average are = " << nAboveAvg (grades,N) <<endl;
sort (grades,N);
cout << "Grades after sorting"<< endl;
for (int i=0; i<n; i++)
cout << grades[i] << " ";
cout<< endl;
system ("pause");
}```

What I have tried:

When I compile this, it shows me
`[error] expected unqualified-id before '{' token`

at line 26 where I highlighted like this >> <<. Please help me
```int maximum (double grades [], int N)
{
double ans = -1;
for (int i=0 ; i<N ; i++)
if (grades [i] > ans)
ans = grades [i];
return ans;
}

>> { <<
double min_value;
int min_index;
double temp;
for (int i =0; i<npts -1 ; i++)```
Posted
Updated 23-Jan-22 8:09am
Comments
Patrice T 29-Mar-18 21:49pm
delete previous question
Member 13754010 29-Mar-18 21:55pm
I did

## Solution 1

It's quite obvious where the problem is. You highlighted it in >> and <<. Just delete the { character. That's it!

Also, if you want to keep your code readable and maintainable, do not ever do this:
C
```int maximum (double grades [], int N)
{
double ans = -1;
for (int i=0 ; i<N ; i++)
if (grades [i] > ans)
ans = grades [i];
return ans;
}```

Do this instead. The curly braces are there to make the code readable, debuggable, and leave no double as to which lines belong in which block. Also, indent your code properly.
C
```int maximum (double grades [], int N)
{
double ans = -1;

for (int i=0 ; i<N ; i++)
{
if (grades[i] > ans)
{
ans = grades [i];
}
}

return ans;
}```

## Solution 2

The tips of Dave are best practice: use indentation and braces for clear code and maintainable code.

But your error is that a new function should start there, but the head got deleted. My guess is that it is a sorting function.
C++
```void sort(double x[], int npts)// <= this or similar is missing
{
double min_value;
int min_index;
double temp;
for (int i =0; i<npts -1 ; i++)
{
min_value = x[i];
min_index = i;
for (int j=i+1; j<npts; j++)
{
if (x[j] < min_value)
{
min_value = x[j];
min_index = j;
}
}
temp = x[min_index];
x[min_index]= x[i];
x[i] = temp;
}
return;
}```

## Solution 3

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>

using namespace std;

struct q ;// node declaration

int isEmpty(struct Queue *q);
{
if (q->rear == q->front)
{
return 1;
}
return 0;
}

void enqueue(struct Queue *q,int time)
{
q->rear = (q->rear + 1) % q->size;
q->time_arr[q->rear] = time;

}
int dequeue(struct Queue *q)
{
int a = -1;

q->front = (q->front + 1) % q->size;
a = q->time_arr[q->front];
}
int main()
{
struct Queue A;
struct Queue B;

A.size = 10;
B.size = 10;

A.front = A.rear = 0;
B.rear = 0;
B.front = 0;

A.time_arr = (int *)malloc(A.size * sizeof(int));
B.time_arr = (int *)malloc(B.size * sizeof(int));

srand(time(NULL));
}

int n;
printf("Enter total number of job : ");
scanf("%d", &n);

int t,x,d,i=0;
float avgt=0, avg[99],avg1=0;
int y=1, z=1;

for (int i =0; i < n; i++);
printf("\nSelect the type of job : \n1.JOB A 2.JOB B\n");
scanf("%d", &x);
if (x == 1)
{
t = rand()%29+1;
enqueue(&A, t);
printf("Execution time is %d minute\n");

}
if (x ==2)
{
t = rand()%29+1;
enqueue(%B, t);
printf("Execution time is %d minute\n", t);

}
}
printf("\nQueue (Job B higher priority than Job A):\n");
if(isEmpty(%B) == 0)
{
printf("Job B(%d) executed.\n",y);
avgt=dequeue(&B);
y++;

while(isEmpty(&B) == 0)
{
avg[i]=avgt;
printf("Job B(%d) with waiting time %.0f minute to be executed.\n",z,avgt);
avgt=avgt+dequeue(&A);
i++;
z++;
}
}

if(isEmpty(&A) == 0)
{
printf("Job A(%d) executed.\n",z);
avgt=dequeue(&A);
z++;

while(isEmpty(&A) == 0)
{
avg[i]=avgt;
printf("Job A(%d) with time %.0f minute.\n",z,avgt);
avgt=avgt+dequeue(&A);
z++;
i++;
}
}
avg1=avg[i-1]/(n-1);
printf("\nAverage waiting time for each job: %.2f minute\n",avgt);
return 0;
}

error : expected unqualified-id before token '{' token at int isEmpty {

Comments
Richard Deeming 24-Jan-22 7:05am
Your error message and code-dump is not a "solution" to this already-answered question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Top Experts
Last 24hrsThis month
 OriginalGriff 140 Richard Deeming 80 Dave Kreskowiak 70 George Swan 35 Andre Oosthuizen 25
 OriginalGriff 2,433 Graeme_Grant 1,110 Richard Deeming 888 Richard MacCutchan 673 Dave Kreskowiak 601

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900