write an algorithm and a program to count the number of
elements in a circularly singly linked list
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 |
What is array of structure in c?
How would you find a cycle in a linked list?
What is the purpose of the following code? Is there any problem with the code? void send(int count, short *to, short *from) { /* count > 0 assumed */ register n = (count + 7) / 8; switch (count % 8) { case 0: do { *to = *from++; case 7: *to = *from++; case 6: *to = *from++; case 5: *to = *from++; case 4: *to = *from++; case 3: *to = *from++; case 2: *to = *from++; case 1: *to = *from++; } while (--n > 0); } }
Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?
what is diffrence between string and character array?
What does %2f mean in c?
how to print value of e(exp1)up to required no of digits after decimal?
write a program in 'c' to find the value of p[i+1]^n.p,i,n are arguments of a macro and n is a integer
sir, i cannot find the way how to write aprogram by using array on queue
What is the difference between procedural and functional programming?
1.int a=10; 2.int b=20; 3. //write here 4.b=30; Write code at line 3 so that when the value of b is changed variable a should automatically change with same value as b. 5.
Is array a primitive data type in c?