What will be the output of the following program on GCC?

Loading

Practice Pointers –

What will be the output of the following program on GCC?

#include <stdio.h>
#include <malloc.h>
int main(){
struct node{
struct node *pre;
struct node *next;
int i;
};
struct node *p,*q;
p=(struct node *) malloc(sizeof (struct node));
q=(struct node *) malloc(sizeof (struct node));
p->i=75;
q->i=90;

p->pre=NULL;
p->next=q;
q->pre=p;
q->next=NULL;
while(p!=NULL){
printf("%d ", p->i);
p=p->next;
}
return 0;
}

What will be the output of the following program on GCC?

Loading

Practice Pointers –

What will be the output of the following program on GCC?

#include <stdio.h>
#include <malloc.h>
#define NULL 0
int main(){
struct node{
int data;
struct node *link;
};
struct node *p,*q;
p=(struct node *) malloc(sizeof (struct node));
q=(struct node *) malloc(sizeof (struct node));
p->data=30;
p->link=q;
q->data=40;
q->link=NULL;
printf("%d ",p->data);
p=p->link;
printf("%d ",p->data);
return 0;
}