-
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);
}
-
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.
-