Quick actions

cmd+k|ctrl+k

Navigation

Languages

9.2al

Snippet info

Language

Cpp

Visibility

public

Author

zackyahmadsyahputra4

Created

2025-12-06T05:33:10.210622Z

Updated

2025-12-26T14:43:56.92989Z

#include <iostream>
#include <cstring>
#include <stdio.h>
// nama : zacky ahmad s
// nim  : 3420240009
using namespace std;
void garis (){
    puts("=================================================");
}
void ttd (char nama[20],char email[20]){
    cout<<"Nama\t: "<<nama<<endl;
    cout<<"Email\t: "<<email<<endl;
}
void program_strlen(){
    char nama[20] ="Zacky Ahmad S";
    garis();
    puts("\tContoh Program Strlen");
    garis();
    cout<<"Nama anda masukan adalah "<<nama<<endl;
    cout<<"Jumlah karakternya adalah "<<strlen(nama)<<endl;
}
void program_strcmp(){
    garis();
    puts("\tContoh Programp 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 {
      puts("Maaf pilihan anda salah...");
    }
    garis();
    ttd ("Zacky","[email protected]");
    return 0;
}
INFO