Program While dan Do While

1. Bilangan genap dari 1 – 20

 

#include<iostream.h>

int main()

{

            int bil;

            bil = 2;

            while (bil<=20)

            {

                        cout<<” “<< bil;

                        bil=1 + bil++;

            }

            cout<<“\n”;

            return 0();

}

 

 

 

 

 

 

 

 

 

 

 

 

Bilangan Ganjil dari 30 – 50

 

#include<iostream.h>

int main()

{

            int bil;

            bil =31;

            while (bil<=50)

            {

                        cout<<” “<<bil;

                        bil=1+bil++;

            }

            cout<<“\n”;

            return 0( );

}

 

 

 

 

 

 

 

 

 

 

 

 

 

2. Program tampilan kelipatan 7 dari 1 – 50

 

#include<iostream.h>

int main()

{

            int bil;

            bil=1;

            do

            {

                        cout<<” “<<bil;

                        bil=6+bil++;

            }

            while (bil<=50);

            cout<<“\n”;

                        return 0();

}

 

 

 

 

 

 

 

 

 

 

 

 

 

#include<iostream.h>

int main()

{

            int i,j;

            i=1;

    while(i<=3)

            {

                        j=i;

                while(j<=3)

                        {

                            cout<<“*”;

                            j++;

                        }

                        cout<<“\n”;

                        i++;

 

            }

           

            return 0();

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: