Quick actions

cmd+k|ctrl+k

Navigation

Languages

Algoritma 9.2

Snippet info

Language

Cpp

Visibility

public

Author

dhafinshabir610

Created

2024-12-14T08:52:37.315327Z

Updated

2025-01-13T04:43:57.017786Z

#include <iostream>
#include <cstring>
#include <stdio.h>
using namespace std;


void garis() {
    puts("===================================");
}

void ttd(char nama[20], char email[20]){
    cout<<"Nama  : "<<nama<<endl;
    cout<<"Email : "<<email<<endl;
}

void program_strlen() {
    char nama[20] = "Dhafin Shabir";
       garis();
    puts("\tContoh Program strlen");
       garis();
    cout<<"Nama yang anda masukan adalah "<<nama<<endl;
    cout<<"Jumlah karakternya adalah "<<strlen(nama)<<endl;
}

void program_strcmp() {
    garis();
    puts("\tContoh program strcmp");
    garis();
       char a1[] = "S"; char a2[] = "s";
    char b1[] = "S";
    cout<<"Hasil Perbandingan "<<a1<<" dan "<<a2<<"->";
    cout<<strcmp(a1,a2)<<endl;
    cout<<"Hasil Perbandingan "<<a2<<" dan "<<a1<<"->";
    cout<<strcmp(a2,a1)<<endl;
    cout<<"Hasil Perbandingan "<<a1<<" dan "<<b1<<"->";
    cout<<strcmp(a1,b1)<<endl;
    
}

int main() {
    int pilih;
    printf("Silahkan pilih program [1/2]: ");cin>>pilih;
    cout<<endl;
    
    if (pilih == 1) {
        program_strlen();
    } else if (pilih == 2) {
        program_strcmp();
    } else {
        printf("Maaf pilihan anda salah..");
    }
    garis();
    ttd("Dhafin","[email protected]");
    return 0;
}
INFO