forked from DHEERAJHARODE/Hacktoberfest2024-Open-source-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLINKLIST.C
48 lines (45 loc) · 928 Bytes
/
LINKLIST.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<stdio.h>
#include<stdlib.h>
struct node{
int no;
struct node *next;
};
int main(){
struct node *head=(struct node*)malloc(sizeof(struct node));
head->next=NULL;
struct node *go=head;
int ascii10=0;
char ans;
int counter=1;
while(1){
printf("Enter value to the node :\n");
printf("(%d). ",counter);
scanf("%d",&go->no);
go->next=(struct node*)malloc(sizeof(struct node));
go=go->next;
go->next==NULL;
printf("a nother node?(Y/y/N/n):");
scanf(" %c",&ans);
printf("%c",ans);
while(1){
if((ans=='Y')||(ans=='y')||(ans=='N')||(ans=='n')){
break;
}else{
printf("Wrong letter : ");
scanf(" %c",&ans);
}
}
if((ans=='N')||(ans=='n')){
break;
}
counter++;
}
printf("The values in the linked list are :");
go=head;
while(go->next!=NULL){
printf("%d ",go->no);
go=go->next;
}
printf("\n");
return 0;
}