Ice-cream of Montu Mia

Montu Mia is a student of “Omok School”. He likes to eat an icecream everyday. But he also likes to …

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

I think there’s a problem.
It says the three separated integers are cost of transportation. So the addition of these three
integers should be the total transport cost. So if i substract it from the money his father gave
him would be the spare money, and if the spare money exceeds 10 he can buy one, if it doesn’t he can’t. So what’s wrong with my code here ?

#include

using namespace std;

int main() {
int n,a,b,c,i;
scanf(“%d” , &n);
scanf(“%d%d%d” , &a,&b,&c);
if(a+b+c < n && n-(a+b+c) >= 10){
printf(“Yes :-D”);
}

else printf("No :-(");

return 0;

}

The tree separate integers are cost of different vehicle. It means if he choose first vehicle then he will need a amount of money and he will have n - a amount of money left and for second one he will need b amount of money and so on.

yeah thanks , got it

#include <stdio.h>

int main() {
int a,b,c,d,e=10;
scanf(“%d”,a);
scanf(“%d %d %d”,&b,&c,&d);
if(e >= a-b || a-c || a-d){
printf(“Yes :-D”);
}
else{
printf(“No :-(”);
}
return 0;
}

problem??

change this line if(e >= a-b || a-c || a-d)
to if(a-b>=10|| a-c>=10||a-d>=10)
Thanks to backbenchermmc for the fix.

mahfuz ,you didn’t get It right
if(a-b>=10|| a-c>=10||a-d>=10)

1 Like

thank you for helping the noobcoders like us ,Mahfuuz!!