//input two integers a and b. find out small and big values between a and b.
//Example if a is 12 and b is 5 then small will be b and big will be a.
//Use a loop to output multiples of 3 from small to big.
//Display their count and sum
The program works fine but i cant display the count of the multiples of 3.
#include<iostream>
usingnamespace std;
int main()
{
int a, b, i, sum=0, count=0;
cout<<"Enter two numbers:";
cin>>a>>b;
cout<<" Multiples of 3 from " << a << " to " << b <<":"<<endl;
if (a<=b)
{
for (i=a; i<=b; i++)
{
if (i % 3 == 0)
cout<<i<<endl;
count ++;
}
}
else {for (i=b; i<=a; i++)
{
if (i % 3 == 0)
cout<<i<<endl;
count ++;
}
}
sum= sum + i;
cout<<"Count ="<<count<<endl;
cout<<"Sum= "<<sum<<endl;
return 0;
}
#include<iostream>
usingnamespace std;
int main()
{
int a, b, i, sum=0, count=0;
cout<<"Enter two numbers:";
cin>>a>>b;
cout<<" Multiples of 3 from " << a << " to " << b <<":"<<endl;
if (a<=b)
{
for (i=a; i<=b; i++)
{
if (i % 3 == 0)
{
cout<<i<<endl;
count ++;
}
}
}
else
{
for (i=b; i<=a; i++)
{
if (i % 3 == 0)
{
cout<<i<<endl;
count ++;
}
}
}
sum= sum + i;
cout<<"Count ="<<count<<endl;
cout<<"Sum= "<<sum<<endl;
return 0;
}