Primary Arithmetic

 avatar
user_6817964
c_cpp
2 years ago
736 B
2
Indexable
#include <iostream>

using namespace std;

main(){
    int a, b;
    while(cin >> a >> b){
        if(a == 0 && b ==0)
            break;

        int carry = 0, c = 0;

        while(a != 0 || b != 0){
            int a_m = a % 10;
            int b_m = b % 10;
            a /= 10;
            b /= 10;
            if(a_m + b_m + c > 9){
                carry++;
                c = 1;
            }
            else{
                c = 0;
            }
        }

        if(carry == 0)
            cout << "No carry operation." << endl;
        else if(carry == 1)
            cout << "1 carry operation." << endl;
        else
            cout << carry << " carry operations." << endl;

    }
}