Posts

Showing posts from November, 2020

PERULANGAN (LOOPING)

Image
LATIHAN PERTEMUAN 9 Membuat tampilan seperti program dibawah dengan menggunakan metode perulangan: 1. While 2. Do..While Program While #include<iostream> #include<conio.h> using namespace std; int main() {     int a=1, b;     while(a<=9)     {     b=a; while (b<=9)     {         cout<<b<<""; b++;     }     cout<<"\n"; a++;     } return 0; }  HASIL INPUT     HASIL OUTPUT   Program Do While #include<iostream> #include<conio.h> using namespace std; int main() {     int a=1, b;     do     {         b=a;         do         {           cout<<b<<""; b++;         }         while (b<=9);         cout<<"\n"; a++;     }     while(a<=9); return 0; } HASIL INPUT HASIL OUTPUT 3. Buatlah program untuk menghitung 10 deret bilangan ganjil dan hasilnya :     1 + 3 + 5 + 7 + 9 + 11 + 13 + 17 + 19 = 100  #include<iostream> #include<conio.h> using namespace std; int main() { int