Page 100 - DCAP407_DATA_STRUCTURE
P. 100
Unit 6: Linked List Operations
LIST1[8]=9;
LIST1[9]=18;
LIST1[11]=16;
LIST1[13]=5;
LIST1[14]=-1;
LIST1[16]=0;
LIST1[18]=7;
HEAD=11;
PTR=HEAD;
printf(“Initially entered list\n”);
while(PTR!=-1)
{
printf(“%d\t”, LIST[PTR]);
PTR=LIST1[PTR];
}
PTR=HEAD;
while(PTR!=-1)
{
MULT(PTR);
PTR=LIST1[PTR];
}
PTR=HEAD;
printf(“\n \n List after traversal:\n”);
while(PTR!=-1)
{
printf(“%d\t”, LIST[PTR]);
PTR=LIST1[PTR];
}
getch();
}
void MULT(int p1)
{
LIST[p1]=LIST[p1]*10;
}
Output:
When you run the program, the following output is obtained:
Initially entered list:
6
79
55
20
15
75
65
66
12
39
35
80
List after traversal:
60
790
550
200
LOVELY PROFESSIONAL UNIVERSITY 93