Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

pow only turns up red, even when including cmath and/or math.h

0 votes
asked Jan 26, 2018 by Nathaniel Athorn (120 points)

Hey all, having some difficulties with a homework assignment. Need to use the power/exponent function for squares and cubes as seen below but I am unable to use the pow function. It shows up red everytime I type it in, no matter what I add or remove. Not sure what to do now, need to get this done though.

#include <iostream>
#include <cmath>
#include <iomanip>
#include <math.h)

using namespace std;

int main()
{
    
    int numBase = 0;
    cout << "Number" << "\tSquare" << "\tCube" << endl;
    cout << numBase << "\t" << numBase << "\t" << numBase << endl;
    numBase += 1;
    cout << numBase; << "\t" << numBase = pow

    
    


    return 0;
}

Thanks!

1 Answer

0 votes
answered Feb 16, 2018 by anonymous
#include <stdio.h>
#include <math.h>
int main()
{
    printf("2*2=%lf",pow(2,2));

    return 0;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...