Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <ctype>
  3. #include <stdlib>
  4. using namespace std;
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8.     char uScores[12];
  9.     int n = 0;
  10.     int sum = 0;
  11.     cout << "Dude, enter the number of scores you want to enter: \n";
  12.     cin >> uScores;
  13.     int intScores = atoi(uScores);
  14.     int aScores[intScores];
  15.     int vScores[intScores];
  16.    
  17.     for(int i = 0; i < intScores; i++){
  18.             cout << "Enter a score: \n";
  19.             cin >> aScores[i];
  20.     }
  21.    
  22.     for(int x = 0; x < intScores; x++){
  23.             if((aScores[x] >= 0) && (aScores[x] <= 100) && (isdigit(aScores[x])))
  24.             {
  25.                           vScores[x] = aScores[x];
  26.             }
  27.     }
  28.  
  29.     int total = (sizeof(vScores) / sizeof(vScores[0]));
  30.    
  31.     cout << "There are " << total << " valid elements in the array. \n";
  32.    
  33.     while(n < total){
  34.         sum += vScores[n];
  35.         n++;
  36.     }
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement