quick question of curiosity about return statements

This is a discussion on quick question of curiosity about return statements within the C Programming forums, part of the General Programming Boards category; Hi... just a quick one... what would: Code: int somefunc(int x){ return x * x; } would this return statement ...

  1. #1
    Matt Conway bobthebullet990's Avatar
    Join Date
    Nov 2005
    Location
    Cambridge
    Posts
    121

    quick question of curiosity about return statements

    Hi... just a quick one...

    what would:

    Code:
    int somefunc(int x){
     
      return x * x;
    
    }
    would this return statement return x squared or something different?
    Many junglists take pride in their belongin to what may be referred to as a globalised drum & bass subculture, as a subculture though, it is not nearly as distinct at gothic or punk!

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Yes, it would return (x * x), which is the same as x squared. At least until it overflows the integer (which happens with numbers bigger than sqrt(INT_MAX), most machines that would be sqrt((2^31)-1) -> 46340). [^ here means to the power of, rather than XOR].

    --
    Mats

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New string functions
    By Elysia in forum C Programming
    Replies: 11
    Last Post: 03-28-2009, 06:03 AM
  2. can some one please tell me the cause of the error ?
    By broli86 in forum C Programming
    Replies: 8
    Last Post: 06-26-2008, 09:36 PM
  3. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 11:17 AM
  4. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 11:50 AM
  5. problem with open gl engine.
    By gell10 in forum Game Programming
    Replies: 1
    Last Post: 08-21-2003, 05:10 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21