Friday, 13 July 2012

Calculate Power Of A Number in C


#include<stdio.h>
#include<conio.h>
void main()
{
long int a,b,c,i,j,d,u;

clrscr();

printf("enter base =");
scanf("%ld",&a);

u=a;

printf("\nenter exponent =");
scanf("%ld",&b);


for(i=0;i<b;i++)
{

    c=a*u;
    a=c;

  }


if(b==1)
{
c=c/u;

}

 printf("%ld",c);
 getch();
 }

No comments:

Post a Comment