Professional Documents
Culture Documents
Function Exercise
Function Exercise
Function Exercise
1. A program in C language is given as follows.
#include <stdio.h> //Line 1
int m_power_n(int,int); //Line 2
int i, result=1; //Line 3
void main() //Line 4
{ //Line 5
int a, b; //Line 6
//Line 7
scanf(“%d %d”, &a, &b); //Line 8
result = m_power_n(a,b); //Line 9
printf(“\n%d to the power of %d is %d.”, a,b, result); //Line 10
} //Line 11
//Line 12
int m_power_n(int r, int s) //Line 13
{ //Line 14
int result =1; //Line 15
//Line 16
for( i=0; i < s; i++) //Line 17
result * = r; //Line 18
return result; //Line 19
} //Line 20