pages

Wednesday, 9 June 2021

c-program to find the power of the number by using function | c-programming

 program to find the power of the number 

In this program we will now input the base and power of the number  form the user and calculate the power of the number by using function  in c-programming.





#include<stdio.h>
#include<conio.h>
int power(int ,int);
void main()
{
         int p,b,a;
         printf("enter the base:-");
         scanf("%d",&b);
         printf("\nenter the power:-");
         scanf("%d",&p);
         a=power(b,p);
         printf("\n the power of the number is %d",a);
         getch();
}
int power(int x,int y)
{
         int i,f=1;
         for(i=0;i<y;i++){
                  f=f*x;
         }
         return(f);
}

output:-





For more c-programming:-






No comments:

Post a Comment