Sunday, July 24, 2011

Multiplication of number using recursion


#include<stdio.h>
#include<conio.h>
main()
{
      int a,b;
      int sum(int a,int b);
      printf("Enter the 1st number :");
      scanf("%d",&a);
      printf("Enter the 2nd number :");
      scanf("%d",&b);
      printf("\n the multiplication %d",sum(a,b));
      getch();
      return 0;
}
int sum(int a,int b)
{
    if(a==0||b==0)
    return 0;
    if(b==1)
    return a;
return (a+sum(a,b-1));
}

Previous Next Home
0 Comments
Comments

Leave a Comment

:)) ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} :)] ~x( :-t b-( :-L x( =))

Twitter Delicious Facebook Favorites More