Quick actions

cmd+k|ctrl+k

Navigation

Languages

algoritma 6-2

Snippet info

Language

Cpp

Visibility

public

Author

raffaisnurasha25

Created

2025-11-15T05:29:29.027704Z

Updated

2025-11-15T05:29:29.027704Z

#include <iostream>
#include <string.h>

using namespace std;

void garis() {
    cout << "------------------------------------------" << endl;
}

char* cek_posisi(char kode) {
    char* posisi;
    posisi = new char[30];

    switch (kode) {
        case 'A':
        case 'a':
            strcpy(posisi, "Junior Programmer");
            break;
        case 'B':
        case 'b':
            strcpy(posisi, "Senior Programmer");
            break;
        case 'C':
        case 'c':
            strcpy(posisi, "Lead Programmer");
            break;
        default:
            strcpy(posisi, "Kode Salah");
            break;
    }

    return posisi;
}

void judul() {
    garis();
    puts("\tProgram Menentukan Posisi");
    garis();
}

int main() {
    char kode_posisi;

    judul();

    cout << "Masukkan Kode Posisi : ";
    scanf("%c", &kode_posisi);

    cout << endl;

    printf("Posisi yang anda pilih adalah %s", cek_posisi(kode_posisi));

    cout << endl;
    garis();

    cout << "Nama   : raffais nur asha" << endl;
    cout << "nim    : 3420240013" << endl;

    return 0;
}
INFO