finding power of number in c language

Download excellent quality study note and ebooks of amie section a on Computing and Informatics (AD 303) in pdf,ppt,doc format
Post Reply
abhijit
Royal Guardian
Royal Guardian
Posts: 310
Joined: Sun Apr 29, 2012 8:55 pm
Location: kolkata
Contact:

finding power of number in c language

Post by abhijit »

include<stdio.h>
#include<conio.h>
long int power(int,int);
void main()
{
int x,n,ans;
clrscr();
printf("\n\t Enter any number : ");
scanf("%d",&n);
printf("\n\t Enter power : ");
scanf("%d",&x);
ans=power(n,x);
printf("\n\t %d ^ %d = %d",n,x,ans);
getch();
}
long int power(int y,int number)
{
long int result;
int i;
result=1;
for(i=1;i<=number;number--)
{
result=result*y;
}
return(result);
}

finding power of number in c language

Sponsor

Sponsor
 

Post Reply

Return to “Computing and Informatics (AD 303)”