Answer to Question #150841 in C# for Rakibul

Question #150841
Using a pointer list, a structure of type node (contains an integer element called data,
and a pointer to a structure of type node called next_node), which has been initialized
to the address of node1, write C statements which will cycle through the list and print
out the value of each nodes data field.
1
Expert's answer
2020-12-14T15:32:17-0500
#include <stdio.h>

struct node
{
    int data;
    struct node* next_node;
};

int main()
{
    struct node node3 = { 3, NULL   };
    struct node node2 = { 2, &node3 };
    struct node node1 = { 1, &node2 };

    struct node* list = &node1;

    while(list)
    {
        printf("%d\n", list->data);
        list = list->next_node;
    }
    
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS