c list
#include <stdio.h>
int main (int argc, char * argv[])
{
int i = 0;
int list[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int run = 1;
int length_of_list; // the number of elements that the list contains
length_of_list = sizeof(list) / sizeof(int); // getting the number
while (run){ //printing the list
printf("The list is: %d\n", list[i]);
i = i + 1;
if (i == length_of_list){ //check if the list has ended
printf("The list has ended!\n");
break; // exit the loop
}
}
return 0;
}
4.67
3
typedef struct node{
int value; //this is the value the node stores
struct node *next; //this is the node the current node points to. this is how the nodes link
}node;
node *createNode(int val){
node *newNode = malloc(sizeof(node));
newNode->value = val;
newNode->next = NULL;
return newNode;
}
Thank you!
3
0
3.63
8
// Node of the list
typedef struct node {
int val;
struct node * next;
} node_t;
Thank you!
8
0
Are there any code examples left?
New code examples in category C
-
C 2022-03-27 22:30:45 Problem Statement Print the following output: \ Input Format IN Output Format \
-
-
-
-
-
-
-