Page 585 - Computer science 868 Class 12
P. 585

23      small=ob2.num;
                   24      }

                   25      else
                   26      {

                   27      big=ob2.num;
                   28      small=this.num;

                   29      }
                   30      while(big>0)

                   31      {
                   32      d1=small%10;

                   33      d2=big%10;
                   34      s=d1+d2+carry;
                   35      big/=10;

                   36      small/=10;

                   37      if(s==0||s==1)  // binary addition
                   38      {
                   39      sum=s;

                   40      carry=0;
                   41      }

                   42      else
                   43      if(s==2)

                   44      {
                   45      sum=0;

                   46      carry=1;
                   47      }

                   48      else
                   49      if(s==3)

                   50      {
                   51      sum=1;

                   52      carry=1;
                   53      }

                   54      else
                   55      {

                   56      System.out.println("ERROR");




                                                                                                                       583
                                                                                                   Internal Assessment  583
   580   581   582   583   584   585   586   587   588   589   590