0
    int** truthtable(int n)
{
int i,k=0,m,a,b;
    a=n;
    int **truthtablearray=(int**)malloc(sizeof(int*)*n);
for(i=0; i<n; i++)
{
    truthtablearray[i]=(int*)malloc(sizeof(int)*pow(2,n));
    truthtablearray[i][k]=1;
    for(k=1; k<pow(2,n); k++)
        {
        m=(pow(2,n)/pow(2,a-1));
        for(b=1; b<=m; b++)
            {
            if(b%2==1)truthtablearray[i][k]=1;
            else truthtablearray[i][k]=0;}

        a--;
        }

}

return truthtablearray;

}

I have included

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

But i have "undefined reference to pow"

What could the reason be?

Rook
  • 5,734
  • 3
  • 34
  • 43

1 Answers1

1

compile as

gcc file.c -lm

or

if c++

g++ file.cpp -lm
coder hacker
  • 4,819
  • 1
  • 25
  • 50