check this way of using list
#include<stdio.h> #include<stack> #include<malloc.h> using namespace std; struct node { int data; struct node * rev; }; int main() { struct node * pass,*start1,*store; stack <int> s1; int i=1,carry=0,n,s; printf("Enter"); scanf("%d",&n); struct node * news=(struct node*)malloc(sizeof(struct node)); news->data=2; news->rev=NULL; start1=news; for(i=1;i<n;i++) { pass=start1; carry=0; while(pass!=NULL) { store=pass; s=carry; carry=(((pass->data)*2)+carry)/10; pass->data=(((pass->data)*2)+s)%10; pass=pass->rev; } if(carry>0) { struct node * news=(struct node*)malloc(sizeof(struct node)); news->data=carry; news->rev=NULL; store->rev=news; } } while(start1!=NULL) { s1.push(start1->data); start1=start1->rev; } while(!(s1.empty())) { printf("%d",s1.top()); s1.pop(); } } correct me if im wrong On Sep 21, 10:30 pm, Dave <dave_and_da...@juno.com> wrote: > 1 followed by x zeros would be 2^x in base 2. > > Dave > > On Sep 21, 8:54 am, rajess <rajeshrules...@yahoo.com> wrote: > > > > > > > > > why you can ,print a 1 followed by x number of zeros -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.