I wrote a program which calculte the power of a number
example 2^5 = 32
program
#include<stdio.h>
#include<conio.h>
void main(){
int a,b,c;
int power();
printf("base value : ");
scanf("%d",&a);
printf("power value : ");
scanf("%d",&b);
c=power(a,b);
printf("value of a power b =%d",c);
getch();
}
when i compile this program an error comes
Error at line 12 : Extra Parameter to call power()
But in this program no error comes
Program
int power(int x,int y){
int k,l,m=1;
k=x;l=y;
for(int i=0;i<l;i++)
m = m*k;
return(m);
}
void main(){
int a,b,c;
printf("base value : ");
scanf("%d",&a);
printf("power value : ");
scanf("%d",&b);
c=power(a,b);
printf("value of a power b =%d",c);
getch();
}
I think there is a problem in function declaration in 1st program.
but according to book function can be declared without specifying arguments. So i declared as "int power();"
Please tell what error means and where is the problem.