Error: 1d return 1 Exit Status

#include <iostream>

using namespace std;
int frequency(int a[], int n, int x)
{
int count = 0;
for (int i = 0; i < n; i++)
{
if (a[i] == x)
count++;
return count;
}

int main();
{
int a[] = { 0, 6, 7, 8, 4 };
int n = 5;
int x = sizeof(a) / sizeof(a[0]);
cout << frequency(a, x, n);
return 0;
}
system("pause");
}

Write your question here.

you have put the code for main() inside the frequency function.
You need to move main() outside the frequency function and remove the semicolon after main().
Thanks :)
Topic archived. No new replies allowed.