#include <stdio.h> void main() { int count, n; float x, y; printf("Enter the values of x and n: \n"); scanf_s("%f %d",&x,&n); y = 1.0; count = 1; /*Initialisantion*/ /*loop begins*/ while(count <= n)/*teasting*/ { y = y*x; count++; /*incrementing*/ }/*loop ends*/ printf("\nx = %f; n = %d; x to power n = %f\n",x,n,y); } /*用for語句*/ #include <stdio.h> void main() { int count, n; float x, y; printf("Enter the values of x and n: \n"); scanf_s("%f %d", &x,&n); y = 1.0; for(count=1;count<=n;count++)/*loop begins*/ { y = y*x; }/*loop ends*/ printf("\nx = %f; n = %d; x to power n = %f\n",x,n,y); }