....IN C PROGRAMMINNG.... ....IN C PROGRAMMINNG.... ....IN C PROGRAMMINNG.... ..
ID: 3847538 • Letter: #
Question
....IN C PROGRAMMINNG....
....IN C PROGRAMMINNG....
....IN C PROGRAMMINNG....
....IN C PROGRAMMINNG....
....IN C PROGRAMMINNG....
....IN C PROGRAMMINNG....
11) Write a valid and compileable for loop that iterates through all the elements of a linked list and counts the number of elements in it. Each element in the list is a "struct Listltem" with a single member nextltem and "mylist" points to the tem at head of the list. Use "currentltem" as your iterator variable and store the total count in itemCount. ListItem *currentltem Int itemCount 0; //your for loop starts underneath this commentExplanation / Answer
//defnition of a node Strut ListItem { struck ListItem * nextITem ; } //define the iterator ListItem *currentItem=NULL; //use the forloop. iterate till null for(currentItem = mylist;currentItem!=NULL;currentItem= currentItem->nextItem) { // increment itemcount itemCount++ ; }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.