Is there a way to find the square of a number (e.g. x^2) instead of having to write y=x*x?
Is there a way to find the square of a number (e.g. x^2) instead of having to write y=x*x?
I am against the teaching of evolution in schools. I am also against widespread
literacy and the refrigeration of food.
Research pow() in <math>, i.e.
-SkipperCode:z = pow(x, y);
"When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow
Code:#include <iostream> #include <cmath> //need for pow() function int main() { int a, b, c; b = a * a; //I would recommend this method for finding a square cout << "Enter a base: "; cin >> a; cout << "Enter an exponent: "; cin >> b; c = pow(a, b); //I would recommend this if raising to uncertain power return 0; } //pow(x, y) is in the form x^y