-2

I had tried running a program which I solved in codeblocks and using math.h library in cs50 ide by Harvard University(which is Ubuntu based). Its giving me an error that library is not included. How to include to my cs50 ide..?

3 Answers3

0

Are you including it in the compiling?

Easiest way to do it is to compile with: make filename

If that doesn't work check you are adding it correctly: #include

lordf
  • 70
  • 1
  • 12
0

Use #include <math.h> to include it

MingisKing
  • 117
  • 13
0

this is the code

#include <cs50.h>
#include <stdio.h>


const int TOTAL = 3;

int main (void)
{
    int scores[TOTAL];
    for (int i = 0; i < TOTAL; i++)
{
    scores[i] = get_int("Score: ");
}

    printf("Average: %f \n", average(TOTAL, scores));
}

float average (int lenght, int array[])
{
    int sum = 0;
    for (int i = 0; i < lenght; i++)
    {
       sum = sum + array[i];
       }
       return sum / (float) lenght;