{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

e2final -...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<stdio.h> #include<conio.h> #include<math.h> # define mx 6 /* RISHI AGARWAL FULL ADDER    ROLL NO 02 SE CMPN A*/ struct stack {  int data[mx];  int top; }; int mul[2*mx+1]; struct stack add(struct stack *p,struct stack *q,int *c) {  struct stack z;  int i,max,t1,t2;  z.top=-1;  if(p->top>q->top)  max=p->top;  else  max=q->top;  for(i=0;i<=max;i++)  {   if(i<=p->top)   t1=p->data[i];   else   t1=0;   if(i<=q->top)   t2=q->data[i];   else   t2=0;   z.data[i]=(t1+t2+(*c))%2;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
  (z.top)++;   if(t1+t2+(*c)<2)   (*c)=0;   else   (*c)=1;  }  return z; } void dectobin(int z,struct stack *p) {  int x,t=mx;  x=z;  p->top=-1;  do  {   (p->top)++;   p->data[p->top]=x%2;   x=x/2;   t--;  }while(t>0); } void display(struct stack *p) {  int z;  z=p->top;  while(z>=0)  {   printf("%d",p->data[z]);   z--;  } } int bintodec(int mu[]) {
Background image of page 2
 int i,x=0;  for(i=0;i<10;i++)   x=x+(mu[i]*pow(2,i));  return x; } void disp(int c,struct stack *a,struct stack *q) {  int i;  printf("%d  ",c);  for(i=mx-1;i>=0;i--)   printf("%d",a->data[i]);
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}