Untitled
Anonymous
plain_text
08/06/2023 12:56 PM
932 B
22
Indexable
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int vowel (char c) {
c = tolower(c);
return (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
}
void kode(char input[]) {
int b = strlen(input);
char huruf[17];
int index = 0;
for (int i = 0; i < b; i++) {
if (!vowel(input[i])) {
huruf[index++] = toupper(input[i]);
}
}
if (index == 0) {
huruf[index++] = 'X';
}
huruf[index] = '\0';
printf("Singkatan: %s\n", huruf);
}
int main() {
char input[100];
printf("Masukkan nama kota >> ");
scanf("%99[^\n]", input);
kode(input);
return 0;
}
Editor is loading...