pgm to find middle element of linklist(in efficent manner)
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 ? | 4 Yes | 0 No |
Post New Answer View All Answers
What are the c keywords?
How do you print an address?
Tell us bitwise shift operators?
#include show(int t,va_list ptr1) { int a,x,i; a=va_arg(ptr1,int) printf(" %d",a) } display(char) { int x; listptr; va_star(otr,s); n=va_arg(ptr,int); show(x,ptr); } main() { display("hello",4,12,13,14,44); }
What's the total generic pointer type?
What is the purpose of clrscr () printf () and getch ()?
How would you obtain the current time and difference between two times?
How can a number be converted to a string?
The number of bytes of storage occupied by short, int and long are a) 2, 2 and 4 b) 2, 4 and 4 c) 4, 4 and 4 d) none
Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.
program to find out date after adding 31 days to a date in the month of febraury also consider the leap year
Explain what are its uses in c programming?
Design a program which assigns values to the array temperature. The program should then display the array with appropriate column and row headings.
State the difference between realloc and free.
How to define structures? ·