So, my friend's program is supposed to find the Multiplicative of Number three then print them out with a comma between the number. And not for the last one.
int a;
int b;
cout<< "First Number = ";
cin>>a;
cout<< "Last Number = ";
cin>>b;
if(a<=b)
{
for(a;a<=b;a++)
{
if(a%3 == 0 && a%2 != 0)
{
cout<<a;
}
if(a<b && a%3==0 && a%2 != 0)
{
cout<< " , ";
}
else if(a==b)
{
cout<< ".";
}
}
}
And after i input
a = 1
b = 20
this is what i expected
3 , 9 , 15.
and this is what i actually get
3 , 9 , 15 , .