Printing Out Numbers are divisible by 3 and 5

So we enter the instance number is n, then n mod 3 == 0, here means if n mod 3 if the result = 0 if the result equals 0 then the number is exhausted dbagi with 3.

algoritmanya
Deklarasi

i: integer {bilangan 1 sampai dengan 100}

Deskripsi

Read i
I ß 1 sampai dengan 100
for (int i=1; i<=100; i++)
if (i mod 3==0)
Write i
Else (i mod 5==0)
Write i

program C++

#include

#include

class bilangan

{

public:

int proses();

private:

int i;

};

int bilangan::proses()

{

cout<<"Program Mencetak Bilangan yg Habis dibagi 3 dan 5";

cout<<" antara 1 sampai 100 : \n";

for(int i=1; i<=100; i++)

{

if(i % 3==0)

{cout<<i<<endl;}

else(i % 5==0);

{cout<<i<<endl;}

}

}

int main()

{

bilangan x;

x.proses();

getch();

}

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: