-
-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathbinStack.c
More file actions
36 lines (36 loc) · 555 Bytes
/
binStack.c
File metadata and controls
36 lines (36 loc) · 555 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "stdio.h"
#include "stdlib.h"
struct xxx
{
int data;
struct xx *link;
};
struct xx *sp=0,*q;
main()
{
int n;
printf("Enter a decimal number :");
scanf("%d",&n);
while(n>0)
{
if(n==0)
{
sp=(struct xx *)malloc(sizeof(struct xx));
sp->data=n%2;
sp->link=0;
}
else
{
q=(struct xx *)malloc(sizeof(struct xx));
q->link=sp;
sp=q;
sp->data=n%2;
}
n=n/2;
}
while(sp!=0)
{
printf("%d ",sp->data);
sp=sp->link;
}
}