BigInteger in Java and C++

code:

for c++ this link link or google search is good but i didn’t found any goood solution yet:
http://codeforces.com/blog/entry/16380

java:

Simple addition:

/**
 * Created by ZakiHP on 6/11/2017.
 */
import java.util.*;
public class AddNumbers {
    public static void main(String[] args){
        int x,y,z;
        System.out.println("Enter two integers to calculate their sum:");
        Scanner in=new Scanner(System.in);
        x=in.nextInt();
        y=in.nextInt();
        z=x+y;
        System.out.println("Sum of entered integeres:"+z);

    }
}

BigInt Sum:

import java.math.BigInteger;
import java.util.Scanner;

/**
 * Created by ZakiHP on 6/11/2017.
 */
public class BigInt {

    public static void main(String[] args) {
        String number1, number2;
        Scanner input = new Scanner(System.in);
        System.out.println("Enter first large number:");
        number1 = input.nextLine();
        System.out.println("Enter second large number:");
        number2 = input.nextLine();
        BigInteger first = new BigInteger(number1);
        BigInteger second = new BigInteger(number2);
        BigInteger sum;
        sum = first.add(second);
        System.out.println("Result of addition: " + sum);


    }
}

 

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published.