Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- using namespace std;
- main(){
- int b = 0, nomor, genap = 0, ganjil = 0, negatif = 0, positif = 0;
- do {
- cout << "Masukkan Bilangan : "; cin >> nomor;
- if(nomor == -999){
- break;
- }
- if(nomor < 0){
- negatif = negatif + 1;
- }else if(nomor > 0){
- if(nomor % 2 == 0){
- genap = genap + 1;
- }else{
- ganjil = ganjil + 1;
- }
- positif = positif + 1;
- }else if(nomor == 0){
- genap = genap + 1;
- }else{
- cout << "Angka tidak ada" << endl;
- break;
- }
- }while(nomor != -999);
- cout << "\n\nJumlah Bil. Genap : " << genap << endl;
- cout << "Jumlah Bil. Ganjil : " << ganjil << endl;
- cout << "Jumlah Bil. Negatif : " << negatif << endl;
- cout << "Jumlah Bil. Positif : " << positif << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment