A linked list is formed from the objects of the class Node. The class structure of the Node is given below:

class Node
int num;
Node next;

Write an Algorithm OR a Method to count the nodes that contain only odd integers from an existing linked list and returns the count.

The method declaration is as follows:

int CountOdd( Node startPtr )

Share code with your friends

Share on whatsapp
Share on facebook
Share on twitter
Share on telegram


					int CountOdd(Node startPtr)
    int c=0;
    Node temp=startPtr;
    while(temp != null)
        if (temp.num  % 2 != 0)
    return c;


Coding Store

Leave a Reply

Your email address will not be published. Required fields are marked *