My issue
My code
#include <stdio.h>
int main(void) {
// your code goes here
int a,b;
int c=(a+b);
int d=(a*b);
scanf("%d,%d",&a,&b);
if(c>d){
printf("%d",c-d);
}
else{
printf("%d",d-c);
}
return 0;
}
Problem Link: ABDIFF Problem - CodeChef
@dhana_1818 your code might be working for the given test cases but the inner test cases which runs might not be satisfactory with your code .
your code is all right but you must give the absolute difference between c and d .
you must include header file and use “abs” function…
i have pasted my code below
hope this helps !!
include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int a,b;
cin>>a>>b;
int diff=abs((a*b)-(a+b));// absolute difference !
cout<<diff<<endl;
return 0;
}
@dhana_1818 Point 1 :- Correct line number 6 as scanf(“%d %d”, &a, &b); There will no be any comma between %d and %d.
Point 2 :- You have initialized your integer c and d as (a+b) and (a*b) before taking input for a and b. So place line 4 and 5 after line 6. i.e Initialize the integer after taking input.