exponent

This is a discussion on exponent within the C Programming forums, part of the General Programming Boards category; hi all you great programmers!!! i'm very new in C...this is my first class and struggling through it. i'm having ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    17

    exponent

    hi all you great programmers!!!
    i'm very new in C...this is my first class and struggling through it.

    i'm having problem with writing this program about exponent.
    here is what i got so far...please help...I'M VERY NEW AT C.
    it didn't turn out what i expected....whats wrong?

    #include<stdio.h>
    int PowFun(int,int); // function prototype
    int main()
    {
    int FirstNum,SecNum,total;
    printf("please enter a number:");
    scanf("%", &FirstNum);
    printf("please enter another number:\n");
    scanf("%d", &SecNum);

    total=PowFun(FirstNum,SecNum);
    printf("the integer to its power is%d", total);
    return 0;
    }
    // the following is the function of PowFun
    int PowFun(int x, int y)
    {
    int total;
    total = x^y;
    return (total);
    }

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Using [code] [/code] tags makes your post look nicer.
    Code:
    int PowFun(int x, int y)
    {
       int total; 
       total = x^y;
       return (total);
    }
    In C, the ^ operator performs an exclusive OR, not exponentiation; C does not have an exponentiation operator.

    There is the function pow.
    Last edited by Dave_Sinkula; 04-14-2003 at 01:39 PM.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    17
    thanks dave

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. mantissa, sign, exponent
    By -EquinoX- in forum C Programming
    Replies: 28
    Last Post: 03-05-2008, 01:25 PM
  2. Shift exponent and comma to match (normalize)
    By luise.valencia in forum C++ Programming
    Replies: 6
    Last Post: 04-14-2005, 11:49 AM
  3. exponent math, calculus?
    By phosphorousgobu in forum C++ Programming
    Replies: 11
    Last Post: 10-20-2004, 10:55 AM
  4. exponent and power problems, please help
    By andreasb in forum C++ Programming
    Replies: 3
    Last Post: 11-11-2003, 07:33 AM
  5. Exponent help
    By flatline911 in forum C++ Programming
    Replies: 4
    Last Post: 08-15-2003, 01:34 AM

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