1. untuk menghitung jumlah kapital
#include <stdio.h>
#include <conio.h>
main()
{
char st[80];
int i, jum_hrf_kecil=0, jum_hrf_besar=0;
puts("masukkan sembarang string");
gets(st);
for(i=0;st[i];i++)
if(st[i]>='a'&&st[i]<='z')
jum_hrf_kecil++;
else
if(st[i]<='A' && st[i]<='Z')
jum_hrf_besar++;
printf("Jumlah huruf besar : %d\n",jum_hrf_besar);
printf("Jumlah huruf kecil : %d\n",jum_hrf_kecil);
getch();
}
#include <conio.h>
main()
{
char st[80];
int i, jum_hrf_kecil=0, jum_hrf_besar=0;
puts("masukkan sembarang string");
gets(st);
for(i=0;st[i];i++)
if(st[i]>='a'&&st[i]<='z')
jum_hrf_kecil++;
else
if(st[i]<='A' && st[i]<='Z')
jum_hrf_besar++;
printf("Jumlah huruf besar : %d\n",jum_hrf_besar);
printf("Jumlah huruf kecil : %d\n",jum_hrf_kecil);
getch();
}
2. kalimat polindrom
#include <stdio.h>
#include <conio.h>
#include <string.h>
void palindrom ( char data [], int x);
main()
{
char word [25];
int len_word;
printf("masukkan kata : ");
gets(word);
len_word=strlen(word);
printf("%d kata ", len_word);
palindrom(word, len_word);
getch();
return 0;
}
void palindrom ( char data [], int x)
{
int i=0, k=0;
while (i<(x-1)/2)
{
if (data [i]!=data[x-1-i])
{
k++;
break;
}
i++;
}
printf ("\n");
if (k==0)
printf ("polindrom");
else
printf("bukan polindrom");
} ak
#include <conio.h>
#include <string.h>
void palindrom ( char data [], int x);
main()
{
char word [25];
int len_word;
printf("masukkan kata : ");
gets(word);
len_word=strlen(word);
printf("%d kata ", len_word);
palindrom(word, len_word);
getch();
return 0;
}
void palindrom ( char data [], int x)
{
int i=0, k=0;
while (i<(x-1)/2)
{
if (data [i]!=data[x-1-i])
{
k++;
break;
}
i++;
}
printf ("\n");
if (k==0)
printf ("polindrom");
else
printf("bukan polindrom");
} ak
ConversionConversion EmoticonEmoticon