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 to create struct variables?
Can you define which header file to include at compile time?
Write a program to swap two numbers without using the third variable?
In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none
the real constant in c can be expressed in which of the following forms a) fractional form only b) exponential form only c) ascii form only d) both a and b
Can 'this' pointer by used in the constructor?
What are local static variables? How can you use them?
There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?
What is c programming structure?
What is the scope of global variable in c?
What is meant by gets in c?
What is the difference between the = symbol and == symbol?
#define PRINT(int) printf("int = %d ",int) main() {< BR> intx,y,z; x=03;y=02;z=01; PRINT(x^x); z<<=3;PRINT(x); y>>=3;PRINT(y); }
What is the correct declaration of main?
I just typed in this program, and it is acting strangely. Can you see anything wrong with it?