Friday, July 24, 2015

Recursion_Multiplication of two number


#include<stdio.h>

int multiply(int a,int b);

int main(){

    int a,b,result;
    printf("Enter two integer: ");
    scanf("%d%d",&a,&b);

    result = multiply(a,b);

    printf("Multiplication of two integer is:%d",result);

    return 0;
}

int multiply(int a,int b){

    static int result=0,i=0;

    if(i < a){
         result= result + b;
         i++;
         multiply(a,b);
    }

    return result;
}

No comments:

Post a Comment