power function in C

Hi,

I wrote a small program to find 2 to the power of 3,
when I tried to execute the following error occured.
How can I solve this problem?

$ cat t1.c
#include <math.h>
#include<stdio.h>

main()
{
int a=2;
int b=3;
int c;
c = a ^ b; /* if i use ** instead of ^ also the same problem */
printf("%10f",c);
}

$ cc -o t1 t1.c

$ a.out
Floating exception(coredump)
$

hi!

but the ^ does not translate to "TO THE POWER OF ..." at all. It is only an XOR Bitwise Operator. you could write your own function for this purpose or use the pow() built-in function from the math.h library.

one more thing, why are you using %f in your printf() while printing an integer?

Rgds
SHAIK

hey, just like shaik said, i would also use pow(). but if you are dying to have your own here is a simple prog.

main()
{
int i;
int a=2; //you can choose any value for a and b
int b=3;

int c=a;

for(i=0;i<b-1;i++){
c*=a;
}
printf("%d",c);
}

also, if you do cc -o t1 t1.c, then your binary is gonna be t1. if you just do cc t1.c, then your binary is a.out (default)