83 23 [Error] 'count' was not declared in this scope (this is the error i am getting in this code and the error is written in the code with the line)
<p>I am getting error in this code i in count what to do?i have idea of count and its functionality and its work it is working in the function  .but  the error is still in <strong>insert function</strong> can anyone pl explain this.</p>

<pre><code>#include&lt;stdio.h&gt;
    #include&lt;conio.h&gt;
    #include&lt;stdlib.h&gt;   struct node {
        int data;
        struct node *next; }*head;

        void append(int num) {
        struct node *temp,*right;
        temp= (struct node *)malloc(sizeof(struct node));
        temp-&gt;data=num;
        right=(struct node *)head;
        while(right-&gt;next != NULL)
        right=right-&gt;next;
        right-&gt;next =temp;
        right=temp;
        right-&gt;next=NULL; }
</code></pre>

<p>add function</p>

<pre><code> void add( int num ) {
        struct node *temp;
        temp=(struct node *)malloc(sizeof(struct node));
        temp-&gt;data=num;
        if (head== NULL)
        {
        head=temp;
        head-&gt;next=NULL;
        }
        else
        {
        temp-&gt;next=head;
        head=temp;
        } } void addafter(int num, int loc) {
        int i;
        struct node *temp,*left,*right;
        right=head;
        for(i=1;i&lt;loc;i++)
        {
        left=right;
        right=right-&gt;next;
        }
        temp=(struct node *)malloc(sizeof(struct node));
        temp-&gt;data=num;
        left-&gt;next=temp;
        left=temp;
        left-&gt;next=right;
        return; }
</code></pre>

<p>This is the function in which i am getting the error can anyone pl explain this?</p>

<pre><code>void insert(int num) {
        int c=0;
        struct node *temp;
        temp=head;
        if(temp==NULL)
        {
        add(num);
        }
        else
    {
    while(temp!=NULL)
    {
        if(temp-&gt;data&lt;num)
        c++;
        temp=temp-&gt;next;
    }
    if(c==0)
        add(num);

   else if(c &lt; count()) \\ 83   23  [Error] 'count' was not declared in this \\scope

        addafter(num,++c);
    else
        append(num);
    } }
</code></pre>

<p>Delete function</p>

<pre><code> int delete(int num) {
    struct node *temp, *prev;
    temp=head;
    while(temp!=NULL)
    {
    if(temp-&gt;data==num)
    {
        if(temp==head)
        {
        head=temp-&gt;next;
        free(temp);
        return 1;
        }
        else
        {
        prev-&gt;next=temp-&gt;next;
        free(temp);
        return 1;
        }
    }
    else
    {
        prev=temp;
        temp= temp-&gt;next;
    }
    }
    return 0; }
    void  display(struct node *r) {
    r=head;
    if(r==NULL)
    {
    return;
    }
    while(r!=NULL)
    {
    printf("%d ",r-&gt;data);
    r=r-&gt;next;
    }
    printf("\n"); }
    int count() {
    struct node *n;
    int c=0;
    n=head;
    while(n!=NULL)
    {
    n=n-&gt;next;
    c++;
    }
    return c; }
    int  main() {
    int i,num;
    struct node *n;
        head=NULL;
        while(1)
        {
        printf("\nList Operations\n");
        printf("===============\n");
        printf("1.Insert\n");
        printf("2.Display\n");
        printf("3.Size\n");
        printf("4.Delete\n");
        printf("5.Exit\n");
        printf("Enter your choice : ");
        if(scanf("%d",&amp;i)&lt;=0){
            printf("Enter only an Integer\n");
            exit(0);
        } else {
            switch(i)
            {
            case 1:      printf("Enter the number to insert : ");
                     scanf("%d",&amp;num);
                     insert(num);
                     break;
            case 2:     if(head==NULL)
                    {
                    printf("List is Empty\n");
                    }
                    else
                    {
                    printf("Element(s) in the list are : ");
                    }
                    display(n);
                    break;
            case 3:     printf("Size of the list is %d\n",count());
                    break;
            case 4:     if(head==NULL)
                    printf("List is Empty\n");
                    else{
                    printf("Enter the number to delete : ");
                    scanf("%d",&amp;num);
                    if(delete(num))
                        printf("%d deleted successfully\n",num);
                    else
                        printf("%d not found in the list\n",num);
                    }
                    break;
            case 5:     return 0;
            default:    printf("Invalid option\n");
            }
        }
        }
        return 0; }
</code></pre>