In this discussion, it is still about the statements "if", "else if" or "else". However, for the operator that we will discuss this time is about modulus or in C++ programming is stated with "%" which means the remainder value. For more details, please see the simple review below:
1. Even
2. Odd
3. Zero
Source Code:
#include<iostream.h>
#include<conio.h>
/**
*bundet.com
*Menentukan Bilangan Bulat, Genap, Ganjil atau Nol
*/
void main() {
int a;
cout << "menentukan bilangan bulat genap/ganjil/nol \n";
cout << "masukkan bilangan : "; cin >> a;
if ( a == 0 )
cout << "bilangan nol " << endl;
else if ( a % 2 == 0 )
cout << "bilangan genap " << endl;
else
cout << "bilangan ganjil " << endl;
getch();
}
That's it, bro, I hope it can be useful. If you have any questions, please just comment below. Thank you.