#include <iostream>
using namespace std;
int main()
{
cout << "entre two numbers";
double x, y;
cin >> x >> y;
if (x != y)
if (x % 2 == 0)
if (y % 2 == 0)
cout << "the two numbers are accepted";
else
cout << "the two numbers are not accepted";
return 0;
}
Asked
Active
Viewed 69 times
-2

Yksisarvinen
- 18,008
- 2
- 24
- 52

Youssef Ahmed
- 3
- 1
-
3[The error is exactly what the compiler tells you.](http://coliru.stacked-crooked.com/a/fb6fc97a99fe134e). Any additional information you need about that? – πάντα ῥεῖ Jan 22 '21 at 16:49
-
You probably mean `int` instead of `double` if you're doing modulo operations. – tadman Jan 22 '21 at 16:51
-
i put int instead of double and the program runs but i do not know why double is wrong – Youssef Ahmed Jan 22 '21 at 16:58
-
Because % is not valid for doubles. You can use this instead: [https://en.cppreference.com/w/cpp/numeric/math/fmod](https://en.cppreference.com/w/cpp/numeric/math/fmod) – drescherjm Jan 22 '21 at 17:01
-
do you mean that when i do modulo operations i must use int ? – Youssef Ahmed Jan 22 '21 at 17:06
-
ok than you so much – Youssef Ahmed Jan 22 '21 at 17:07
-
The duplicate discusses this. – drescherjm Jan 22 '21 at 17:11
1 Answers
0
You have to declare the variables of 'int' type instead of double and your error will get resolved.
Write below line. int x,y;

PRIYA SHARMA
- 36
- 2