Math, asked by parulkushwaha8897, 1 year ago

Given two numbers. Add the numbers and find the count of carries in their addition

Answers

Answered by muskanc918
6

#include<stdio.h>

int main()

{

unsigned long long int a,b,m,n,rem_m,rem_n,judge=0,sum,count;

while((scanf("%llu%llu",&m,&n))==2)

{

if(m==0 && n==0)

{

break;

}

count=0;

while(m!=0 && n!=0)

{

rem_m=m%10;

rem_n=n%10;

if(judge==1)

{

rem_m++;

}

sum = rem_m+rem_n;

judge=0;

if(sum>=10)

{

count++;

judge++;

}

m=m/10;

n=n/10;

}

if(count==0)

{

printf("No carry operation.\n");

}

else

{

printf("%llu carry operations.\n",count);

}

}

return 0;

}

Similar questions