So as you can see from the topic im a beginner on c++ and i have an assignment to find the sum between numbers n to m which are divided by 3, my question is how to show the odd numbers here's the code i wrote:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
usingnamespace std;
int main()
{
int n=5,m=50,s=0;
while(n<=m)
{
if(n%3==0)
s=s+n;
n++;
}
cout<<"Sum= "<<s;
return 0;
}