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
Can a local variable be volatile in c?
Describe explain how arrays can be passed to a user defined function
What is function prototype in c language?
Write a code to determine the total number of stops an elevator would take to serve N number of people.
What is optimization in c?
how to find binary of number?
Is there a way to jump out of a function or functions?
Tell me what is null pointer in c?
WRITE A CODE IN C TO SEARCH A FILE FROM NOTEPAD FILE.
How the c program is executed?
What is getch () for?
Explain what’s a signal? Explain what do I use signals for?
How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?
What is the difference between text and binary i/o?
What is volatile keyword in c?