Pointers and Linked Lists: Linked Lists #include current=top; while(current!=NULL) { cout<data<<" " current=current->next; } cout<data=.1; for (i=2;i<=10;i++) { current ->next%3Dnew node; current=current->next; current ->data=i/10.0; } current ->next=NULL; This makes sure the list is NULL terminated. ; output: 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 This NULL terminates the list. Now you can write a program that creates a linked list with 26 nodes, fills them with the letters of the alphabet, and then prints them. Use three separate loops: one for creating one for filling, and one for printing, Make sure the last node points to NULL.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 18PE
icon
Related questions
Question

Please code using C++ and only use the headers <iostream>. The use of any other headers will not be accepted. Thank you!

Pointers and Linked Lists: Linked Lists
#include <iostream>
current=top;
while(current!=NULL)
{
cout<<current->data<<" ";
current=current->next;
using namespace std;
struct node
{
double data;
node * next;
};
int main()
{
node *top, * current;
int i;
top=new node;
current=top;
top->data=.1;
for (i=2;i<=10;i++)
{
current ->next=new node;
current=current->next;
current ->data=i/10.0;
}
current ->next=NULL;
This makes sure the list
is NULL terminated.
}
cout<<endl;
return 0;
}
output:
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
This NULL
terminates the list.
Now you can write a program that creates a linked list with 26 nodes, fills them with the
letters of the alphabet, and then prints them. Use three separate loops: one for creating,
one for filling, and one for printing. Make sure the last node points to NULL.
Transcribed Image Text:Pointers and Linked Lists: Linked Lists #include <iostream> current=top; while(current!=NULL) { cout<<current->data<<" "; current=current->next; using namespace std; struct node { double data; node * next; }; int main() { node *top, * current; int i; top=new node; current=top; top->data=.1; for (i=2;i<=10;i++) { current ->next=new node; current=current->next; current ->data=i/10.0; } current ->next=NULL; This makes sure the list is NULL terminated. } cout<<endl; return 0; } output: 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 This NULL terminates the list. Now you can write a program that creates a linked list with 26 nodes, fills them with the letters of the alphabet, and then prints them. Use three separate loops: one for creating, one for filling, and one for printing. Make sure the last node points to NULL.
16: linkedList.cpp) Write a program in three parts. The
first part should create a linked list of 26 nodes. The second
part should fill the list with the letters of the alphabet. The
third part should print the contents of the linked list.
Transcribed Image Text:16: linkedList.cpp) Write a program in three parts. The first part should create a linked list of 26 nodes. The second part should fill the list with the letters of the alphabet. The third part should print the contents of the linked list.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Introduction to Coding
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning