not displaying output why?

0 votes
asked Aug 11, 2018 by Akshay Baser (120 points)
using namespace std;
struct node
    int data;
    struct node *next;
struct node *p=NULL;
int main()
    struct node *head,*temp;
    int i,n;
    cout<<"Enter no. of nodes";
    head=(struct node*)malloc(sizeof(struct node));
    cout<<"\nEnter data of first node ";
        temp=(struct node*)malloc(sizeof(struct node));
        cout<<"\nEnter data";
    return 0;

1 Answer

0 votes
answered Aug 11, 2018 by virendra singh (140 points)
Head is not linked with the other created nodes...... and variable temp is getting modified many times.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.