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
Differentiate between static and dynamic modeling.
When c language was developed?
what do the 'c' and 'v' in argc and argv stand for?
How can a program be made to print the name of a source file where an error occurs?
Explain what are the different data types in c?
What is sizeof c?
What are terms in math?
Why shouldn’t I start variable names with underscores?
What is a void pointer? When is a void pointer used?
What is .obj file in c?
How do shell structures work?
Why c is called a mid level programming language?
What is include directive in c?
Differentiate call by value and call by reference?
What is an example of structure?