write an algorithm and a program to count the number of
elements in a circularly singly linked list



write an algorithm and a program to count the number of elements in a circularly singly linked lis..

Answer / rakesh soni

struct node
{
int info;
struct node *next;
};
main()
{
struct node *head,*temp;
// here insert the elements in circular link list & suppose
//head have the starting pointer of circular link list
//head is not null
int count =1;
temp=head;
while(temp->next!= head)
{
count++;
temp=temp->next;
}
printf(" No of Elements = %d",count);
}

Is This Answer Correct ?    12 Yes 14 No

Post New Answer

More C Interview Questions

in ‘C’ language for Matrix Multiplication fails” Introspect the causes for its failure and write down the possible reasons for its failure.

0 Answers   TCS,


What language is lisp written in?

0 Answers  


Do you know the purpose of 'register' keyword?

0 Answers  


HOW CAN ADD OUR FUNCTION IN LIBRARY.

5 Answers  


Program to find the sum of digits of a given number until the sum becomes a single digit

8 Answers   InterGraph,






Can math operations be performed on a void pointer?

0 Answers  


What is the modulus operator?

0 Answers  


c program to compute AREA under integral

0 Answers   Infosys,


What is typedef example?

0 Answers  


Expand the following LKB BKL FFG

0 Answers  


What is the right way to use errno?

0 Answers  


1 1 1 1 2 1 1 3 3 1 1 4 6 4 1

3 Answers  


Categories