Write a function power ( a, b), to calculate the value of a raised to b.
#include <stdio.h>
#include <conio.h>
long power ( int, int ); /* Function prototype declaration */
void main ( )
{
int m, n;
long pow;
clrscr ( );
printf("\n\n\t\t Enter first number...:"); scanf("%d", &m);
printf("\n\n\t\t Enter second number...:"); scanf("%d", &n);
pow = power ( m, n ); /* Function calling */
printf("\n\n\t\t %d To the Power %d = % ld", m, n, pow );
getch ( );
}
long power ( int i, int j ) /* Function Definition */
{
int a;
long b = 1;
for ( a = 1; a <= j; a++ )
{
b = b * i;
}
return ( b );
}
Click here to contact us`
#include <stdio.h>
#include <conio.h>
long power ( int, int ); /* Function prototype declaration */
void main ( )
{
int m, n;
long pow;
clrscr ( );
printf("\n\n\t\t Enter first number...:"); scanf("%d", &m);
printf("\n\n\t\t Enter second number...:"); scanf("%d", &n);
pow = power ( m, n ); /* Function calling */
printf("\n\n\t\t %d To the Power %d = % ld", m, n, pow );
getch ( );
}
long power ( int i, int j ) /* Function Definition */
{
int a;
long b = 1;
for ( a = 1; a <= j; a++ )
{
b = b * i;
}
return ( b );
}
Click here to contact us`
No comments:
Post a Comment