program to find middle element of linklist?
Answer Posted / abdur rab
struct node {
int data;
struct node* next;
};
int mid_element ( struct node* _node )
{
struct node* cur_ptr;
struct node* cur_next_ptr;
if ( NULL == _node ) return ( -1 );
else {
cur_ptr = _node;
cur_next_ptr = _node;
while ( ( NULL != cur_ptr -> next )
&& ( NULL != cur_next_ptr -
> next )
&& ( NULL != cur_next_ptr -
> next -> next ) )
{
cur_ptr = cur_ptr -> next;
cur_next_ptr = cur_next_ptr ->
next -> next;
}
}
return ( cur_ptr -> data );
}
| Is This Answer Correct ? | 8 Yes | 2 No |
Post New Answer View All Answers
What is malloc calloc and realloc in c?
Stimulate calculator using Switch-case-default statement for two numbers
Write a program to use switch statement.
What is boolean in c?
What is the difference between volatile and const volatile?
How to get string length of given string in c?
What are the similarities between c and c++?
largest Of three Number using without if condition?
difference between Low, Middle, High Level languages in c ?
How to draw the flowchart for structure programs?
Is register a keyword in c?
develop algorithms to add polynomials (i) in one variable
Is return a keyword in c?
a c code by using memory allocation for add ,multiply of sprase matrixes
How can you draw circles in C?