C program to find power of given number.

Question:

Write a Program in C to find out value of given power(X,Y) of number using recursion.

Source Code:

#include<stdio.h> void Pow1(int x,int y) { if(y==0) { printf("1"); } else { printf(x*Pow1(x,(y-1))); } } int main() { int x,y; printf("Enter the value of x and y\n"); scanf("%d \n %d \n",&x,&y); printf("Value is:\n"); Pow1(x,y); return 0; }

Output:

Enter the value of x and y 2 2 Value is: 4

Comments

Popular posts from this blog

Introduction to Python.

Decision Making Statement.