Byang's Additions
Limits
1s, 512 MB
Byang is learning how to add numbers. However, he gets confused whenever there is a carry.
To help Byang you need to write a program that will read two integers and determine if Byang will encounter any carry when adding these two numbers.
For example when adding 182 and 243 Byang will encounter a carry:
To help Byang you need to write a program that will read two integers and determine if Byang will encounter any carry when adding these two numbers.
For example when adding 182 and 243 Byang will encounter a carry:
182
+ 243
-----
5 (Carry 0)
---
25 (Carry 1; This will confuse Byang)
---
425 (Carry 0)
On the other hand, when adding 123 and 321 Byang will not encounter any carry, and it will not confuse Byang: 123
+ 321
-----
4 (Carry 0)
---
44 (Carry 0)
---
444 (Carry 0)
Input
The input will contain two space-separated integers A and B (0 ≤ A, B < 1000000).
Output
Print “Yes” if adding A and B will confuse Byang, otherwise “No”.
#include<stdio.h>
int main()
{
int num1,num2,t1,t2,flag=0;
scanf("%d%d", &num1, &num2);
while(num1!=0,num2!=0)
{
t1=num1%10;
t2=num2%10;
if(t1+t2>9)
{
flag=1;
break;
}
num1/=10;
num2/=10;
}
if(flag==0)
printf("No");
else
printf("Yes");
}