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
A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream
Differentiate fundamental data types and derived data types in C.
The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?
why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above
Can a file other than a .h file be included with #include?
Explain the difference between malloc() and calloc() function?
What is a constant and types of constants in c?
What is property type c?
to find the closest pair
How do you sort filenames in a directory?
How can you draw circles in C?
In a switch statement, what will happen if a break statement is omitted?
Explain what are its uses in c programming?
How is a structure member accessed?
What is action and transformation in spark?