PRINT NUMBERS WHICH ARE DIVISIBLE BY 3 BUT NOT BY 5 UPTO N

/*PROGRAM TO PRINT NUMBERS WHICH ARE DIVISIBLE BY 3 BUT NOT BY 5 UPTO N*/

#include<conio.h>

#include<iostream.h>

class divide

{

int i,n;

public:

void input();

void output();

};

void divide::input()

{

cout<<“Enter the limit: “;

cin>>n;

}

void divide::output()

{

cout<<“Numbers upto “<<n<<” which are divisible by 3 and not by 5 are: \n”;

for(i=1;i<=n;i++)

{

if(i%3==0 && i%5!=0)

cout<<i<<”  “;

}

}

void main()

{

divide d1;

clrscr();

d1.input();

d1.output();

getch();

}

Leave a Reply

Your email address will not be published. Required fields are marked *