Rewrite the code- buid the linked list without dummy node

Assignment Help C/C++ Programming
Reference no: EM13837286

Rewrite the code- buid the linked list without dummy node

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
struct Node {
int info;
Node* next;
};
void recycleList (Node * current) {
if(current != nullptr) {
recycleList (current->next);
delete (current);
}
}
int main () {
int n;
cout <<"How long a list do you want? "<<endl;
cin>>n;
Node *head = new Node ();
head->info =0;
head->next = nullptr;
Node *current = head;
for (int i = 1; i <= n; i++) {
current->next = new Node ();
current->next->info =i;
current= current->next;
}
current->next = nullptr;
cout<<"Printing the list: "<<endl;
current = head->next;
while(current != nullptr) {
cout<<current->info <<' ';
current = current->next;
}
cout<<endl;
recycleList(head);
return 0;
}

Reference no: EM13837286

Questions Cloud

The direction of the shifts in equilibriums and risk premium : In 2010, and 2011, the government of Greece risked defaulting on its debt due to a severe budget crisis. Using bond market graphs as shown in class show the effect on the risk premium between U.S. Treasury debt and comparable maturity Greek debt. Ple..
Describe the historical development of theoretical approach : Describe the historical development of theoretical approaches
Processes of transportation economics : Explain how the processes of transportation economics play a major role in transportation decisions of the organization. Describe how the supply chain of this company contributions to customer service levels.
Interest rates to rise when nominal money supply is fixed : The president of the United States announces in press conferences in a press conference that he will fight the higher inflation rate with a new anti-inflation program. Predict what will happen to interest rates if the public believe him. Why should a..
Rewrite the code- buid the linked list without dummy node : Rewrite the code- buid the linked list without dummy node
The thickness of the pressure vessel : A cylindrical pressure vessel, with a diameter of 40cm and a wall thickness of 10mm is made of steel (isotropic, with Young's modulus = 200GPa; Poisson's ratio = 0.28) and is pressurized to 20MPa. The longitudinal and hoop stresses in the wall, σl an..
Determine heat transfer co-efficient : Temperature profile given as T(y) = 20+80e-800y Determine heat transfer co-efficient at y=0, thermal conductivity, k=0.62W/mK
Federal open market committee presentation : Learners are to research the current value and the expected future changes in the following economic indicators:
How the organization could leverage the golden circle : Select a product or service that is beneficial to the organization. Samsung Galaxy. Explain how the organization could leverage the golden circle to appeal to even more consumers

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd