Page 586 - Computer science 868 Class 12
P. 586

57       System.exit(0);
                58       }

                59       ob1.ar[ob1.pos]=sum;
                60       ob1.pos++;

                61       }
                62       if(carry==1)

                63       ob1.ar[ob1.pos++]=carry;
                64       return ob1;

                65       }
                66       void display() // print result

                67       {
                68       System.out.println("RESULT :-");
                69       for(int i=this.pos-1;i>=0;i--)

                70       System.out.print(this.ar[i]);

                71       System.out.println();
                72       }
                73       public static void main()

                74       {
                75       binadd obm1=new binadd();

                76       binadd obm2=new binadd();
                77       binadd obm3=new binadd();

                78       System.out.println("FIRST INPUT :- ");
                79       obm1.input();

                80       System.out.println("SECOND INPUT :- ");
                81       obm2.input();

                82       obm3=obm1.add(obm2);
                83       System.out.println("\nThe Added Binary Result is: ");

                84       obm3.display();
                85           } //Close of Main

                86       } //Close of Class

              Output of the preceding program is as follows:
              First Input

              Enter Binary Number: 1010011
              Second Input




                584584  Touchpad Computer Science-XII
   581   582   583   584   585   586   587   588   589   590   591