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
How are 16- and 32-bit numbers stored?
why wipro wase
Are the variables argc and argv are local to main?
What is structure of c program?
Explain what does the function toupper() do?
What is call by value in c?
How can you find the day of the week given the date?
Explain what happens if you free a pointer twice?
Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?
Why main is used in c?
What is a header file?
Explain what standard functions are available to manipulate strings?
What is the basic structure of c?
How can I read/write structures from/to data files?
Is it better to use malloc() or calloc()?