Thread: squares

  1. #1
    Registered User abrege's Avatar
    Join Date
    Nov 2002


    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.

  2. #2
    Registered User
    Join Date
    Apr 2002
    Research pow() in <math>, i.e.

    z = pow(x, y);
    "When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow

  3. #3
    Registered User
    Join Date
    Nov 2002
    #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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Generating an image of squares?
    By vopo in forum C# Programming
    Replies: 3
    Last Post: 10-21-2008, 10:15 AM
  2. Forced moves trouble!!
    By Zishaan in forum Game Programming
    Replies: 0
    Last Post: 03-27-2007, 06:57 PM
  3. pass error before char
    By bazzano in forum C Programming
    Replies: 3
    Last Post: 03-26-2006, 12:00 PM
  4. Magic Squares!
    By ZAM777 in forum C++ Programming
    Replies: 1
    Last Post: 04-28-2004, 03:34 PM
  5. perfect squares?
    By ahalya in forum C++ Programming
    Replies: 2
    Last Post: 10-14-2001, 09:38 PM