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

What is a lookup table in c?

0 Answers  


what is ANSI and ISO

7 Answers   HCL,


When is a void pointer used?

0 Answers  


Is stack a keyword in c?

0 Answers  


consider the following structure: struct num nam{ int no; char name[25]; }; struct num nam n1[]={{12,"Fred"},{15,"Martin"},{8,"Peter"},{11,Nicholas"}}; ..... ..... printf("%d%d",n1[2],no,(*(n1 + 2),no) + 1); What does the above statement print? a.8,9 b.9,9 c.8,8 d.8,unpredictable value

4 Answers   TCS,






actually i have 2 years teaching experience as computer faculty but now i am a DBA but when i go for interview many peoples asked me why i left my teaching profession and why i want to come in this field kindly give me the proper answer of this queston

3 Answers   Ramco,


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

1 Answers  


What is the proper way of these job Tell me about there full work

0 Answers   EDS,


Write a programme to find even numbers without using any conditional statement?

3 Answers   ADD Software, Infosys,


Explain About fork()?

0 Answers   TISL,


Differentiate between Macro and ordinary definition.

0 Answers   Motorola,


Difference between Shallow copy and Deep copy?

0 Answers  


Categories