Skip to content

Instantly share code, notes, and snippets.

@DiegoNaterasPonce
Created March 9, 2016 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DiegoNaterasPonce/8b10c51506af75c22a24 to your computer and use it in GitHub Desktop.
Save DiegoNaterasPonce/8b10c51506af75c22a24 to your computer and use it in GitHub Desktop.
#Quiz5.2
#include <iostream>
#include <iomanip>
using namespace std;
int z = 0, number;
float calc;
float find_threes (int y[], int x)
{or (int i = 0; i < x; i++)
{
calc = y[i] % 3;
number = calc;
if (number == 0)
z = z + y[i];
}
return z;
}
int main ()
{
int sum;
int x [sum];
cout << "Give me the amount of numbers to sum : \n";
cin >> sum;
for (int i = 0; i < sum; i++)
{
cout << "Tell me a number: ";
cin >> x[i];
}
cout << "The sum of the numbers that are divisible by three is : " <<find_threes (x, sum) <<endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment