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 list and returns the count.
the method declaration is as follows:
int CountOdd(Node startPtr)
Answers
Answered by
0
int CountOdd(Node startPtr)
{ int count=0;
while((startPtr.node!=null)&&(startPtr.num%2!=0))
{
count++;
}
return count;
}
{ int count=0;
while((startPtr.node!=null)&&(startPtr.num%2!=0))
{
count++;
}
return count;
}
Similar questions