How to reverse a linked list in C++

#include <bits/stdc++.h>
using namespace std;
struct node
{
int num;
node *next;
}*st; //node constructed
void createList(int n);
void reverse(node *st);

int main()
{
int n,num,item;

cout<<"Enter the number of nodes: ";
cin>>n;
createList(n);
cout<<"After reversing :\n";
reverse(st);
return 0;
}
void createList(int n) //function to create linked list.
{
struct node *frntNode, *tmp;
int num, i;

st = (struct node *)malloc(sizeof(struct node));
if(st == NULL)
{
cout<<"Memory can not be allocated";
}
else
{

cout<<"Enter the data for node 1: ";
cin>>num;
st-> num = num;
st-> next = NULL; //Links the address field to NULL
tmp = st;

for(i=2; i<=n; i++)
{
frntNode = (struct node *)malloc(sizeof(struct node));
if(frntNode == NULL) //If frntnode is null no memory cannot be allotted
{
cout<<"Memory can not be allocated";
break;
}
else
{
cout<<"Enter the data for node "<<i<<": "; // Entering data in nodes.
cin>>num;
frntNode->num = num;
frntNode->next = NULL;
tmp->next = frntNode;
tmp = tmp->next;
}
}
}
}
void reverse(node *st) //function to reverse linked list
{
if (st == NULL)
return;
reverse(st->next);

cout<<st->num<<"\t";
}
Output:
Enter the number of nodes: 5
Enter the data for node 1: 10
Enter the data for node 2: 20
Enter the data for node 3: 30
Enter the data for node 4: 40
Enter the data for node 5: 50
After reversing :
50 40 30 20 10