<div>This is the code I used (cpp attachment available):</div>
<div>
<p><font face="courier new,monospace" color="#006600">/*<br>0 mod 3 = 0<br>1 mod 3 = 1<br>2 mod 3 = 2<br>3 mod 3 = 0</font></p>
<p><font face="courier new,monospace"><font color="#006600">so for all x mod 3 = 0<br>*/</font><br><font color="#3333ff">#include</font> <iostream.h><br><font color="#3333ff">void</font> main(){<br> <font color="#3333ff">int</font> n=1, sum=0;<br>
<font color="#3333ff">while</font> (n<10){<br> <font color="#3333ff">if</font>((n%3)==0){<br> cout<<n<<", ";<br> sum+=n;<br> }<br> <font color="#3333ff">if</font>((n%5)==0){<br> cout<<n<<", ";<br>
sum+=n; <br> }<br> n++;<br> }cout<<"\n\nsum = "<<sum<<endl;<br>}</font></p></div>
<div>
<p>Output: </p>
<p>3, 5, 6, 9 </p>
<p>Sum = 23</p>
<p> </p></div>