ceil and a-b problem ?? can any1 find bug in this code??

#include
#include<stdio.h>

using namespace std;

int main() {

int a , b;

scanf("%d%d",&a,&b);

int c = a-b;

c= (c/10)*10 + (c%10 + 1)%10;

printf("%d\n",c);
return 0;

}

I AM JUST CHANGING LAST DIGIT OF CODE TO INCREMENT BY 1 , IF THE LAST DIGIT IS 9 THEN IT IS REPLACED BY 0

I think your code is failing for the following test case :

10 1

Your code will give 0 as the answer while 0 can’t be. You can simply do it like, find the difference and if the difference%10 is 9, then print diff-1 else print diff+1.

yeahhh got you !!!