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
write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?
What is use of integral promotions in c?
Why double pointer is used in c?
How do you list a file’s date and time?
What is the use of c language in real life?
is it possible to create your own header files?
What is return type in c?
what is a constant pointer in C
Explain setjmp()?
why return type of main is not necessary in linux
Write a program to swap two numbers without using the third variable?
What is storage class?
Why do we use pointer to pointer in c?
What is volatile variable in c with example?
Lists the benefits of c programming language?