Hello guys i need help,
I need to write a program that count how many nubers can be divide in a interval from k to n, exemple in a interval from 1 - 10 theare "3" numbers that can be divide with 3, here is my program:
1.
#include <iostream.h>
void main()
{
int k,x,n;
cout <<"k = ";
cin >> k;
cout << "n = ";
cin >> n;
x = k + 1;
for (x>k;x<n;x++)
{
if (k%3==0; n%3==0)
cout << ((n-k)/3)-1;
else
if (k%3!==0; n%3==0)
cout <<((n-k)/3);
else
if (k%3!==0; n%3!==0)
cout <<((n-k)/3);
}}
or
2.
#include <iostream.h> // But this program just write ex. from 1 - 10
void main() ( 3, 6, 9), but I need that he write there
{ 3 numbers.
int k,x,n,t;
cout <<"k = ";
cin >> k;
cout << "n = ";
cin >> n;
for (x=k;x<=n;x++)
{
if(x%3==0)
cout << x;
else
cout <<" ";
}}
Can anyone help!!