Created
April 5, 2016 02:08
-
-
Save batmantec/3085ef3cb8ead203c68cf8f33abbcd85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using std::cout; | |
using std::cin; | |
using std::endl; | |
int checkMod3(int checkNum){ | |
int work, ans; | |
work = checkNum%3; | |
if (work == 0){ | |
ans = checkNum; | |
} else{ | |
ans = 0; | |
} | |
return ans; | |
} | |
int main(){ | |
int i = 0, exitLoop, forLoop, sum = 0; | |
cout << "Digit the total of number you will try: "; | |
cin >> i; | |
exitLoop = i; | |
int input[i], check[i]; | |
for (i = 0; i != exitLoop; i++) { | |
cout << "Digit the number you want to try: "; | |
cin >> input[i]; | |
check[i] = checkMod3(input[i]); | |
if (check[i] != 0){ | |
sum = sum + check[i]; | |
} | |
} | |
cout << "The numbers that where divisable by 3 are: "; | |
for (i = 0; i != exitLoop; i++) { | |
check[i] = checkMod3(input[i]); | |
if (check[i] != 0){ | |
cout << check[i] << " "; | |
} | |
} | |
cout << endl; | |
cout << "The sum of the numbers that are divisible by 3 is: " << sum << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment