Hey guys, im in need of writing a program using loop structure that reads in 5 integers one by one , and calculates the sum of the values that are multiples of 3 and displays the result.
I have written this simple prgram, the only problem with it ofcourse is that it enters MANY integers until one that is not a multiple of 3 is entere (false statement). Any ideas would be much appreciated..
#include<iostream>
using namespace std;
int main ()
{
int num, total;
total = 0;
cout<<"Please input an integer : ";
cin>>num;
while (num%3==0)
{
total=total+num;
cout<<"please input an integer : ";
cin>>num;
}
cout<<"The total of the integers divisible by 3 is : "<<total<<endl;
system("pause");
return 0;
}