akbarbasya26

ganjil genap total

Nov 18th, 2019
132
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <stdlib.h>
  3. using namespace std;
  4.  
  5. main (){
  6. int b=0, nomor, genap = 0, ganjil = 0;
  7. for (int a=1; a <=10; a++){
  8. cout << "bilangan : "; cin >> nomor ;
  9. if (nomor % 2 == 0){
  10. genap = genap +1;
  11. }else{
  12. ganjil = ganjil + 1;
  13. }
  14. b = b + nomor ;
  15. }
  16.  
  17. cout << "Jumlah bil. ganjil :" << ganjil << endl;
  18. cout << "Jumlah bil. genap :" << genap << endl;
  19. cout << " total jumlah bil :" << b << endl;
  20. return 0;
  21. }
RAW Paste Data