Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctype>
- #include <stdlib>
- using namespace std;
- int main(int argc, char *argv[])
- {
- char uScores[12];
- int n = 0;
- int sum = 0;
- cout << "Dude, enter the number of scores you want to enter: \n";
- cin >> uScores;
- int intScores = atoi(uScores);
- int aScores[intScores];
- int vScores[intScores];
- for(int i = 0; i < intScores; i++){
- cout << "Enter a score: \n";
- cin >> aScores[i];
- }
- for(int x = 0; x < intScores; x++){
- if((aScores[x] >= 0) && (aScores[x] <= 100) && (isdigit(aScores[x])))
- {
- vScores[x] = aScores[x];
- }
- }
- int total = (sizeof(vScores) / sizeof(vScores[0]));
- cout << "There are " << total << " valid elements in the array. \n";
- while(n < total){
- sum += vScores[n];
- n++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement