How do you insert an element at the beginning of the list?

1
void insertatbegin (int item)
{
node *p;
p = (node *p) malloc (sizeof (node));
p → info = item;
if (start == null)
    p → next = start;
else
    p → next = null;
start = p;
}
2
void insertatbegin (int item)
{
node *p;
p = (node *p) malloc (sizeof (node));
p → info = item;
if (start == null)
    p → next = null;
else
    p → next = start;
start = p;
}
3
void insertatbegin (int item)
{
node *p;
p = (node *p) malloc (sizeof (node));
p → item = info;
if (start == null)
    p → next = null;
else
    p → next = null;
start = p;
}
4
void insertatbegin (int item)
{
node *p;
p → info = item;
if (start == null)
    p → next = start;
else
    p → next = start;
start = p;
}

Sponsored

hivanix.in

Visit

This quiz is brought to you by hivanix.in

🌐 Web App Development

Quick Navigation