Kamis, 11 Maret 2021

Prakerja (newvideo.course-net.com) - Selection - 3.2 Selection Switch Case

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

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()

{

    //Selection If else, Switch case

    int input;

    printf("1. print angka 123\n");

    printf("2. print angka 456\n");

    printf("3. print angka 789\n");

    printf("Pilih Menu : ");

    scanf("%d", &input);fflush(stdin);

    

    switch(input){

        case 1:

            printf("123\n");

            break;

        // break : untuk stop proses

        case 2:

            printf("456\n");

            break;

        case 3:

            printf("789\n");

            break;

        default:

        // default : else di switch case

            printf("menu yang anda pilih tidak ada\n");

            break;

    }

    

    

    return 0;

}


Tidak ada komentar:

Posting Komentar