Advertisement

X to the power n

X to the power n, using loop.

#include<stdio.h>
#include<conio.h>


void main()
{  clrscr();
   int i,x,n,a=1;
   printf("Enter x then n=");
   scanf("%d %d",&x,&n);
   for(i=1;i<=n;i++)
   {   a=a*x;  }
   printf("output is=%d",a);
   getch();

}

No comments:

Post a Comment

Please comment bellow. Share your knowledge