Hi, I have a problem with this:
Code:
#include<iostream.h>
typedef unsigned long int ulong;
int main()
{
ulong a,b;
while(cin >> a >> b)
{
if(a==0 && b==0)
return 0;
int count = 0, cry = 0;
while(a || b)
{
int x = a%10, y = b%10;
a/=10;
b/=10;
if((x+y+cry)>9)
{
cry = 1;
count++;
}
else
cry = 0;
}
if(count>1)
cout << count << " carry operations." << endl;
else if(count == 1)
cout << "1 carry operation." << endl;
else
cout << "No carry operation." << endl;
}
return 0;
}
IO:
9 1
1 carry operation.
9 0
1 carry operation.
9 0
No carry operation
9 0
No carry operation
9 1
No carry operation
9 1
1 carry operation.
09 1
No carry operatio
1 carry operation
But what you'll tell about it's output? Can anyone explain...why this is so ...???