Advertisement
DinovaWidytianto

unknow

Nov 19th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int nilai[100];
  8. int n, jumlah = 0, kurang = 0 ;
  9.  
  10. cout<<"masukan jumlah data : ";
  11. cin>>n;
  12. for(int i=1; i <=n; i++)
  13. {
  14. cout<<"masukan data ke-"<<i<<" : " ;
  15. cin>>nilai[i];
  16. }
  17.  
  18. for(int i=1; i <=n; i++)
  19. {
  20. cout<<nilai[i];
  21. if(i%2==0)
  22. {
  23. kurang;
  24. }
  25. else{
  26. jumlah = jumlah + nilai[i];
  27. }
  28.  
  29. }
  30. cout<<"\n";
  31. cout<<"\n";
  32. cout<<"pengurangan genap : "
  33. cout<<"jumlah ganjil : "<<jumlah<<endl;
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement