Can we ignore else keyword and write rest of the code which is not if's part in non void or int return type function as shown in below example .What difference does it make ?
int searhLL(Node *head, int x){
Node *curr = head;
int pos = 1;
while (curr != NULL)
{
if (curr->data == x)
return pos;
else // can we remove else keyword here ?
{
pos++;
curr = curr->next;
}
}
return -1;}
Another Example
Node *delHead(Node *head){
if(head==NULL)return NULL;
else // ?
{
Node *temp = head->next;
delete head;
}
return temp;
}