Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
//Q2.1) WAP to implement a linked list, insert data at the end and then print the linked list. #include
#include
using namespace std; struct node{ int data; node* next; void setData(int d){ data=d; next=NULL; } }; void InsertAtTail(node* &tail,int data){ node* newNode=(node*)malloc(sizeof(node)); newNode->setData(data); tail->next=newNode; tail=newNode; } void PrintLinkedList(node* &head){ node* temp=head; while(temp!=NULL){ cout<
data<<" "; temp=temp->next; } cout<
setData(1); node* tail=head; InsertAtTail(tail,2); InsertAtTail(tail,3); InsertAtTail(tail,4); InsertAtTail(tail,5); cout<<"After Insertion: "; PrintLinkedList(head); return 0; } /* OUTPUT: After Insertion: 1 2 3 4 5 */
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)