There's nothing in the output. Only blinking cursor. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

There's nothing in the output. Only blinking cursor.

#include<stdio.h> #include<stdlib.h> struct node { int rno; struct node *next; }; void main() { int n,i,r; struct node *head; //head=(struct node *)malloc(sizeof(struct node)); head=NULL; //scanf("%d",&n); n=5; for(i=1;i<=n;++i) { r=i; //scanf("%d",&r); if(head==NULL) { head=(struct node *)malloc(sizeof(struct node)); head->rno=r; head->next=NULL; } struct node *tmp; tmp=head; int f=0; while(tmp!=NULL) { if(tmp->rno==r) { f=1; break; } tmp=tmp->next; } if(f=0) { tmp->nex

15th Mar 2020, 8:01 AM
Ayush Dubey
Ayush Dubey - avatar
4 Answers
+ 2
Before creating a new node you should traverse list to check existing value. If there is no such value then create a new node, set its next member to head value, and set head to new node address: https://code.sololearn.com/cwvgqrjmmRyn
15th Mar 2020, 9:29 AM
andriy kan
andriy kan - avatar
+ 1
https://code.sololearn.com/cuKVKOfYVfvG/?ref=app
15th Mar 2020, 8:02 AM
Ayush Dubey
Ayush Dubey - avatar
+ 1
The code is attached
15th Mar 2020, 8:03 AM
Ayush Dubey
Ayush Dubey - avatar
0
Why your main is void any remove comments https://code.sololearn.com/cLTyWsNUMZMG/?ref=app
15th Mar 2020, 8:08 AM
ツSampriya😘ツ
ツSampriya😘ツ - avatar