C Saved Program: fragrant-city

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


#include<stdio.h>
#include<stdlib.h>
struct node{
    int data;
    struct node *next;
};

struct node *start = NULL;

int main(){
    char ch;
    struct node *newnode,*currentnode;
    do{
          newnode = (struct node*)malloc(sizeof(struct node));
          printf("enter the data to be stored in the node");
          scanf("%d",&newnode->data);
          newnode->next = NULL;
          if(start == NULL){
          start = newnode;
          currentnode = newnode;
          }
          else{
          currentnode->next = newnode;
          currentnode = newnode;
          }
          printf("DO YOU WANT TO CREATE AN ANOTHER NODE ????");
          scanf("%c",&ch);
    }
    while(ch != 'n');
    printf("the entered list is:\n");
    while(start != NULL){
        printf("%d--->",start->data);
        start=start->next; 
    }
    return 0;
}
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs