Write recursive procedures for the following problems :
1)Factorial
2)Print linked list
3)Print reverse linked list
int fact(int n) {
if (n == 0) return 1;
else return n * fact(n-1);
}
void PrintList(Node* curr)
{
if (curr==NULL)
{
cout << "\n";
return;
}
cout << curr->data <<endl;
PrintList(curr->next);
}
Comments
Leave a comment