These are the methods of my program, when I divide between 0 the error message is printed and then if they print a series of random numbers (I understand the cout of the main is not executed correctly) What is the best way to check that Do not divide between 0?
#include <iostream>
using namespace std;
int dividir(int a, int b) {
if (b == 0) {
cout << "ERROR";
}
else {
return a / b;
}
}
int main(){
int x=3; int y=0;
cout<<dividir(x,y);
}