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 the = symbol and == symbol?
Explain what is #line used for?
What are called c variables?
int main() { Int n=20,i; For(i=0;i<=n;i--) { Printf(“-“); Return 0;
What is chain pointer in c?
How will you divide two numbers in a MACRO?
Which node is more powerful and can handle local information processing or graphics processing?
What is line in c preprocessor?
When is a void pointer used?
What is volatile variable in c with example?
What is non linear data structure in c?
Do character constants represent numerical values?
What is %lu in c?
By using C language input a date into it and if it is right?
What is wrong with this program statement?