Advertisement
Cnvmendoza

Six Int

Nov 6th, 2021
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void inputInt(void);
  5.  
  6. main(){
  7.     inputInt();
  8. }
  9.  
  10. void inputInt(void){
  11.     int input;
  12.     int getOnes, getTens, getHundreds;
  13.     int ones = 0, tens = 0, hundreds = 0;
  14.     cout << "Type Six Integers . . . " << endl;
  15.     for (int no = 1; no<=6; no++){
  16.         cout << endl << no << ". "; cin >> input;
  17.             getOnes = input%10;
  18.             //cout << endl << getOnes << endl;
  19.             getTens = input%100/10;
  20.             //cout << endl << getTens << endl;
  21.             getHundreds = input%1000/100;
  22.             //cout << endl << getHundreds << endl;
  23.             ones += getOnes;
  24.             tens += getTens;
  25.             hundreds += getHundreds;
  26.     }
  27.     cout << "Sum of all ones: " << ones << endl;
  28.     cout << "Sum of all tens: " << tens << endl;
  29.     cout << "Sum of all hundreds: " << hundreds << endl;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement