menu bar

Saturday, 9 April 2016

Diberikan suatu bilangan bulat positif. Cetaklah bilangan bulat tersebut secara terbalik,
secara iteratif maupun rekursif



#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
int a;
    cout << "menentukan bilangan bulat positif/negatif/nol \n";
    cout << "masukkan bilangan : "; cin >> a;
 
    if ( a == 0 )
        cout << "bilangan nol " << endl;
    else if ( a % 2 == 0 && a > 0 )
        cout << "bilangan genap positif " << endl;
    else if ( a % 2 == 0 && a < 0 )
        cout << "bilangan genap negatif " << endl;
    else if ( a % 2 != 0 && a > 0 )
        cout << "bilangan ganjil positif " << endl;
    else
        cout << "bilangan ganjil negatif " << endl;
return 0;
}

No comments:

Post a Comment