# can any body help me.

#include<stdio.h>
int main()
{
int A,B,diff,C;
printf(“enter A and B\n”);
scanf("%d%d",&A,&B);
diff=A-B;
C=diff-1;
printf("%d",C);
return 0;

}whats wrong in this program .showing wrong answer after submission.in ciel A-B problem. help me.

**printf(“enter A and B\n”); **

??

Remove this line.

Also, your code will break when A==B.
For example, for input `3 3` your code prints -1 but the answer should also be positive other than containing same number of digits as the difference of A and B.

You are almost there. You just need to check for one special boundary case where it makes a two digit difference. For example, when last digit is 9 adding 1 makes 10 which makes a 2 digit difference. Just add two more lines to your code as follows and your are good.

``````#include<stdio.h>

int main() {
int A,B,diff,C;
//printf("enter A and B\n");
scanf("%d%d",&A,&B);

diff=A-B;

if(diff%10==9) C=diff-1;
else C=diff+1;

printf("%d",C);

return 0;
}``````

You don’t have to “Enter A and B” while solving a problem on any problem, format your problem as per testcase only.

#include<stdio.h>
#include<math.h> int main() {
int a,b;
scanf("%d %d",&a,&b);
if((a-b)%10 == 9)
{
printf("%d\n",a-b-1);
}
else
{
printf("%d",a-b+1);
}
return 0; }

Hope this helps!

firstly i guess you cannot give
printf(“enter A and B\n”)
u cannot simply give it since the programs mentions to take inputs, and moreover it says take two numbers as input so just take two numbers as input ;

``````int main()
{
int a,b,c;
scanf("%d %d",&a,&b);
c=a-b;
if(c%10==9)
c=c-1;
else
c=c+1;

printf("%d",c);
}``````
//