Linked list C: Dynamic Data Structures: - 21648

Request Posted by
jocdrew21

jocdrew21

Earned: $21.25
Request Detail
Price: $30
  • From: Computer Science, Programming
  • Due on: Tue 06 Aug, 2013 (03:54pm)
  • Asked on: Tue 06 Aug, 2013
  • Due date has passed, but you can still Post Solution.
Description
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include<stdio.h>
#include<stdlib.h>
 
struct list
{
    int value;
    struct list *next;
};
void printlist(struct list * root, int length)
{
    int i;
    for(i = 0; i < length; i++)
    {
        printf("%d ",root -> value);
        root = root -> next;
    }
    printf("\n");
}
int main()
{
    int i;
    struct list *root,*temp,*prev;
    root=malloc(sizeof(struct list));
    temp=root;
    for(i=0;i<5;i++)
    {
        printf("Enter the value : ");
        scanf("%d",&temp->value);
        struct list *temp1;
        temp1=malloc(sizeof(struct list));
        prev=temp;
        temp->next=temp1;
        temp=temp1;
         
         
    }
    int flag=1;
    do
    {
        if(i!=5)
        {
            printf("Enter the value : ");
            scanf("%d",&temp->value);
             
        }
        printlist(root,i);
        printf("Do you want to add one more element 1 or 0 : ");
        scanf("%d",&flag);
        if(i!= 5)
        {
            struct list *temp1;
            temp1=malloc(sizeof(struct list));
            temp -> next=temp1;
            temp=temp1;
        }
        i++;
         
    }
        while(flag==1);
     
     
}
1 Solution for Linked list C: Dynamic Data Structures:
Title Price Category solution By purchased  
Linked list C: Dynamic Data Structures:
$30.00 no category sarmad_junaid 1 time(s)
Please Login or Register to Submit the Solution for the Request