//Compile using gcc -lm code.c #include #include int main(){ int i,x, n,n0; int Prod, ProdSeq; printf("Enter the value of x and n: (both positive int) \n"); scanf("%d %d",&x,&n); n0=n; Prod=1; ProdSeq=x; printf("[[Prod*ProdSeq^n=X^n0]], [[%f %f]] Prod=%d, ProdSeq=%d, n=%d \n", Prod*pow(ProdSeq,n), pow(x,n0), Prod, ProdSeq, n); while(n > 0) { if ((n%2)==1){ Prod=Prod*ProdSeq; } n=n/2; ProdSeq = ProdSeq* ProdSeq; printf("[[Prod*ProdSeq^n=X^n0]], [[%f %f]] Prod=%d, ProdSeq=%d, n=%d \n", Prod*pow(ProdSeq,n), pow(x,n0), Prod, ProdSeq, n); } printf("[[Prod*ProdSeq^n=X^n0]], [[%f %f]] Prod=%d, ProdSeq=%d, n=%d \n", Prod*pow(ProdSeq,n), pow(x,n0), Prod, ProdSeq, n); printf("Result of %d ^%d = %d\n", x, n0, Prod); return 0; }