Senin, 15 Maret 2021

Prakerja (newvideo.course-net.com) - Teknik Coding Dasar Untuk Menjadi Apps Developer - Recursive & Struct - 7.1 Recursive

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




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>


int angka(){

    int a = 5;

    printf("%d", a);

    

    return angka();

}


int factorial(int n){

    if(n == 0 || n == 1){

        return 1;

    }else{

        return n * factorial(n - 1);    

    }

}


int main()

{

    //Recursive

    //adalah function yang memanggil dirinya sendiri

    int hasil = factorial(3);

    

    printf("Hasil factorial = %d", hasil);

    

    return 0;

}

Tidak ada komentar:

Posting Komentar