A program for floating number to be raised to an integer number using function.
2. A program for floating number to be raised to an integer number using function.
Codes
/*A program for floating number to be raised to an integer number using function*/
/*Programed by Jitendra Kr Yadav
10116
22 Mar,2011*/
#include<stdio.h>
#include<conio.h>
void power(float, int);
main()
{
float a;
int b;
printf(“Enter the number: “);
scanf(“%f”,&a);
printf(“Enter the value of power: “);
scanf(“%d”,&b);
power(a,b);
getch();
}
void power(float x,int y)
{
float z=x;
for(int i=1;i<=y-1;i++)
{
x=x*z;
}
printf(“The value is: %.2f\n\n”,x);
printf(“Press any key to continue…”);
}
Output
Enter the number: 2.5
Enter the value of power: 2
The value is: 6.25
Press any key to continue…