-4
  #include<iostream>//Pls note:Only header allowed...

As this is the C++ i dont think so any other header is needed for that math function.

using namespace std;
int comparator(int audience[][2], int index1, int index2) {

    int b1, e1;
    int b2, e2;
    b1 = audience[index1][1];
    e1 = audience[index1][2];
    b2 = audience[index2][1];
    e2 = audience[index2][2];

    double re1;
    re1 = pow(b1, e1);
    cout << re1 << endl;

    double re2 = pow(b2, e2);
    cout << re2 << endl;

    if (re1 == re2)
    {
        return 0;
    }

    if (re1 > re2)
    {
        return -1;
    }

    if (re1 < re2)
    {
        return 1;
    }
}

//Nothing has to be done with the rest of the two functions.

void sorting(int audience[][2], int N, int &i_index, int &j_index)
{

    int i, j, temp;

    for (i = 0; i<N - 1; i++)
    {
        if (audience[i][2] < audience[i + 1][2])
            continue;
        else
            i_index = i;
        break;
    }

    for (i = N; i > 1; i++)
    {
        if (audience[i][2]>audience[i - 1][2])
            continue;
        else
            j_index = i;
        break;
    }

    for (i = i_index + 1; i < j_index - 1; i++)
    {
        min = audience[i_index + 1][2];
        for (i = )
            if (audience[i_index][1] > audience[i_index + 1][1])
            {
                temp = audience[i_index + 1][1];
                audience[i_index + 1][1] = audience[i_index][1];
                audience[i_index][1] = temp;
            }
    }

    for (i = i_index + 1; i <= j_index - 1; i++)
    {
        min = audience[i][2];
        for (j = i_index + 2; j <= j_index - 1; j++)
        {
            if (min > audience[j][2])
            {
                temp = audience[i_index + 2][2];
                audience[i_index + 1][2] = audience[i_index][2];
                audience[i_index][2] = temp;
            }

        }
    }
}

void merge(int audience[][2], int mergedarray[][2], int N, int i_index, int    j_index)
{
}

int main()
{
    int audience[100][2], mergedmarks[100][2];
    int i, N;
    int index1 = 0, index2 = 0;
    int comp_result;
    cout << "Enter the value of N : ";
    cin >> N;    // Enter size of the table
    cout << "Enter the base and exponent for " << N << "rows " << endl;

    for (i = 0; i < N; i++)
        cin >> audience[i][0] >> audience[i][1];    //Enter numbers in the table

    cout << endl << "Checking Function 1: Compare ecodes for 5 index pairs" << endl;
    for (i = 0; i < 5; i++)
    {
        cout << "\nEnter indices of row1 and row2 that you want to compare: ";
        cin >> index1 >> index2;
        if (index1 < 0 || index2 < 0 || index1 >= N || index2 >= N)
            continue;
        comp_result = comparator(audience, index1, index2);

        if (comp_result == -1)
            cout << "ecode of index 1 is greater than ecode of index2" << endl;
        else if (comp_result == 1)
            cout << "ecode of index 1 is less than ecode of index2" << endl;
        else if (comp_result == 0)
            cout << "ecode of index 1 is equal to ecode of index2" << endl;
    }
    cout << endl;
    int index_i = 0, index_j = N;
    sorting(audience, N, index_i, index_j);

    cout << "Checking Function 2: Printing sorted array " << endl;
    for (i = 0; i < N; i++)
        cout << audience[i][0] << " " << audience[i][1] << endl;
    cout << endl;

    cout << "index i: " << index_i << "\nindex j: " << index_j << endl;


    cout << endl << "Checking Function 3: Printing Merged Array " << endl;
    merge(audience, mergedmarks, N, index_i, index_j);
    int merge_array_size = index_i + (N - (index_j + 1));
    for (i = 0; i < N; i++)
        cout << mergedmarks[i][0] << " " << mergedmarks[i][1] << endl;
    cout << endl;
    return 0;
}

This is the whole problem. I have to still edit the merge function. That is the whole problem.This is all.

J-Mik
  • 896
  • 7
  • 8

2 Answers2

0

You need to include the pow header, which is math.h, in order to use it.

add at the beginning of your file:

#include <math.h>
#include <iostream>

using namespace std;
J-Mik
  • 896
  • 7
  • 8
  • [`using namespace std` is a bad idea](http://stackoverflow.com/questions/1452721/why-is-using-namespace-std-in-c-considered-bad-practice). – juanchopanza Apr 02 '16 at 16:14
  • well that's what he needs for his code to execute. I think using namespace std; in the cpp file, not the header, is fine. is there a reason why it shouldn't be used? – J-Mik Apr 02 '16 at 16:17
  • 2
    **−1** `using namespace std` is a bad idea in the global scope in a header file. It can very easily cause name collisions. E.g. `std::distance`. – Cheers and hth. - Alf Apr 02 '16 at 16:18
  • @juanchopanza: Sorry for the noise I didn't see what you referred to. – Cheers and hth. - Alf Apr 02 '16 at 16:19
  • **0** Retracted the downvote because this is most likely not a header file. I was confused by @juanchopanza's comment. – Cheers and hth. - Alf Apr 02 '16 at 16:24
  • @Cheersandhth.-Alf I think it is reasonable advice, even for a .cpp file. Especially if it is full of long, messy functions as is the case here. I have seen this go wrong too many times (of course, writing concise, sensible code always helps to mitigate this.) – juanchopanza Apr 02 '16 at 16:27
  • Well, OP did actually already added `using namespace std`, even if that's obfuscated by the bad formatting of the question (and the code). – Bob__ Apr 02 '16 at 16:30
  • true, he modified his post several times though. His post should be clearer now. – J-Mik Apr 02 '16 at 17:33
0

POW is declared in math.h header file so use

#include<math.h>
secretgenes
  • 1,291
  • 1
  • 19
  • 39