dimanche 8 juillet 2018

C++ task based on if statements

I'm quite new to programming and I started a quiz that would help me learn to code, today I got a problem that I don't know how to solve. It's based on If statements. This is the task: "After becoming very popular, Mark received a total of gifts from his fans. Now he wants to move to a bigger house and have to put all the presents in boxes to move. Because he's ordered, Mark wants to put in every box exactly B gifts. We can imagine that Mark can get as many boxes as possible. The two numbers A and B are read from the keyboard. The program will display on screen if it is possible for Mark to move respecting the condition or otherwise impossible. Here's what i tried, but it says it is incorrect.

#include <iostream>
using namespace std;
int main() {
int A;
int B;
cin>>A>>B;
if ((A/B)==2){
cout<<"possible";
}
if ((A/B)!=2){
    cout<<"impossible";
}
return 0;
}

Any kind of help is appreciated

Aucun commentaire:

Enregistrer un commentaire