JUN7

Ganjil : negatif , Genap : positif

Nov 18th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. using namespace std;
  4.  
  5. main(){
  6.     int b = 0, nomor, genap = 0, ganjil = 0, negatif = 0, positif = 0;
  7.     do {
  8.         cout << "Masukkan Bilangan : "; cin >> nomor;
  9.        
  10.         if(nomor == -999){
  11.             break;
  12.         }
  13.         if(nomor < 0){
  14.             negatif = negatif + 1;
  15.         }else if(nomor > 0){
  16.             if(nomor % 2 == 0){
  17.                 genap = genap + 1;
  18.             }else{
  19.                 ganjil = ganjil + 1;
  20.             }
  21.             positif = positif + 1;
  22.         }else if(nomor == 0){
  23.             genap = genap + 1;
  24.         }else{
  25.             cout << "Angka tidak ada" << endl;
  26.             break;
  27.         }
  28.     }while(nomor != -999);
  29.     cout << "\n\nJumlah Bil. Genap   : " << genap << endl;
  30.     cout << "Jumlah Bil. Ganjil  : " << ganjil << endl;
  31.     cout << "Jumlah Bil. Negatif : " << negatif << endl;
  32.     cout << "Jumlah Bil. Positif : " << positif << endl;
  33.     return 0;
  34. }
Add Comment
Please, Sign In to add comment