Jumat, 12 Maret 2021

Prakerja (newvideo.course-net.com) - Array & Pointer - 5.1 Array

 /******************************************************************************


https://www.onlinegdb.com/online_c++_compiler


                              Online C++ Compiler.


               Code, Compile, Run and Debug C++ program online.


Write your code in this editor and press "Run" button to compile and execute it.




*******************************************************************************/




#include <stdio.h>




using namespace std;




int main()


{


    // pointer, array, struct

    

    // //array 1 dimensi

    

    // int angka [4] = {5,6,7,8};

    // printf("isi dari array angka : ");

    // for(int i = 0; i < 4; i++){

    //     printf("%d ", angka[i]);

    // }

    

    //array 2 dimensi

    //angka[baris][kolom]

    

    int angka [2][4] = {

                            {1,2,3,4},

                            {5,6,7,8}

                        };

    for(int j = 0; j < 2; j++){

        printf("isi dari baris ke - %d : ", j);

        for(int i = 0; i < 4; i++){

            printf("%d ", angka[j][i]);

        }    

        printf("\n");

    }



    return 0;


}


Tidak ada komentar:

Posting Komentar