Tampilkan postingan dengan label Codingan3. Tampilkan semua postingan
Tampilkan postingan dengan label Codingan3. Tampilkan semua postingan

Rabu, 16 Maret 2016

Pemograman Perulangan

Assalamu'alaikum wr.wb
Kali ini saya akan memposting Pemrograman Perulangan
  1. #include <iostream>
    using namespace std;
    /* run this program using the console pauser or add your own getch, system("pause") or input loop */

    int main(int argc, char** argv) {
        int n, i;
        for ( n=0, i=10 ; n!=i ; n++, i-- ){
            cout<<"Nilai n = "<<n<<" -- ";
            cout<<"Nilai i = "<<i<<endl;
        }
        return 0;
          Output:

  

2.  #include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
    int h=0;
    while (h<5){
        cout<<" Nilai h : "<<h<<endl;
        h++;
    }
    return 0;
}
 
Output:



 3. #include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
    int i, a;
    for (int i=1; i<3; i++){
    cout<<"\nPerkalian "<<i<<" ";
    for (int a=1; a<=3 ;a++ ){
        cout<<i<<" * "<<a<<" = "<<a*i<<" ";
    }   
    }
    cout<<endl;

    return 0;
}

Output:

TERIMA KASIH DAN SEMOGA BERMANFAAT
Wassalamu"alaikum wr.wb