0 0 votes How is the"do" function working here? What will be the output? Programming in C + – Samujjal Das 1.9k views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
0 0 votes a is printed infinite times because all the time loop check the address part of first node which is always true RAJESHWAR YADAV answered Dec 27, 2016 RAJESHWAR YADAV comment Share Follow See all 8 Comments 8 8 Comments reply Samujjal Das commented Dec 27, 2016 reply Follow flag And what does the do-while loop do? 0 0 replyShare RAJESHWAR YADAV commented Dec 27, 2016 reply Follow flag i m also taking about do while loop 0 0 replyShare Samujjal Das commented Dec 27, 2016 reply Follow flag infinite a's is not in option. 0 0 replyShare RAJESHWAR YADAV commented Dec 27, 2016 reply Follow flag what r the option ?? 0 0 replyShare Samujjal Das commented Dec 27, 2016 reply Follow flag This is the error if I compile the program!! 0 0 replyShare Samujjal Das commented Dec 27, 2016 reply Follow flag #include <stdio.h> struct node { char data; struct node *link; }; struct node *head=NULL; struct node *tail=NULL; void do(struct node *p) { if(p) { printf("%c",p->data); { do { printf("%c",p->data); } while(p->link); } } } void createList(char val) { struct node *newNode; newNode = (struct node*)malloc(sizeof(struct node)); newNode->data = val; if(head == NULL) { head = newNode; } else { tail->link = newNode; } tail = newNode; tail->link = NULL; } int main(void) { int i=0; char ch; for(i=0;i<4;i++) { scanf("%c",&ch); createList(ch); } do(head); return 0; } 0 0 replyShare Samujjal Das commented Dec 27, 2016 reply Follow flag Options 0 0 replyShare RAJESHWAR YADAV commented Dec 27, 2016 reply Follow flag answer is wrong 1 1 replyShare Please log in or register to add a comment.