Skip to content

Commit

Permalink
Taking input through console
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilatkan committed Feb 20, 2020
1 parent 9ceb067 commit 8c54a7b
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions LLtakinginput.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include<iostream>
using namespace std;
class node
{
public:
int data;
node *next;

node(int d)
{
data=d;
next=NULL;
}
};

void insertathead(node*&head,int data)
{
node*n=new node(data);
n->next=head;
head=n;
}

void buildlist(node*&head)
{
int data;
cin>>data;
while(data!=-1)
{
insertathead(head,data);
cin>>data;
}
}
void print(node*head)
{
while(head!=NULL)
{
cout<<head->data<<"->";
head=head->next;
}
}

int main()
{
node*head=NULL;
buildlist(head);
print(head);

return 0;


}

0 comments on commit 8c54a7b

Please sign in to comment.