CONTOH I

#include <stdio.h>
#include <conio.h>
#include <ctype.h>
main()
{ //deklarasi fungsi string
char string1[] = {‘T’,’u’,’r’,’b’,’o’,’ ‘,’c’,”};
char string2[] = “Turbo C”;
char *string3 = “Turbo C”;
char string4 [20];
char pStr;
int i = 0;

printf(“Nama : \t(……………..)\n”);
printf(“NIM : \t(……………….)\n\n”);

printf(“string 1 = %s\n”,string1);
printf(“string 2 = %s\n”,string2);
printf(“string 3 = %s\n”,string3);

for(i=0 ; string2[i]!=0 ; i++)
string2[i] = toupper(string2[i]);
printf(“string 2 = %s\n”, string2);

pStr=string2[i]; //simpan nilai variabel string2 dalam pStr

while (pStr!=”)
{
pStr = tolower(pStr);
pStr++;
}
printf(“string 2 = %s\n”, string2);
puts(“Tuliskan sembarang string :”);
string4[20]=scanf(“%s”,&string4);

printf(“string 4 = %s\n”,string4);
getch();
}

CONTOH II

#include <stdio.h>
#include <conio.h>
#include <ctype.h>
main()
{
int c;
printf(“Nama : \t(…………….)\n”);
printf(“NIM : \t(………………..)\n\n”);

printf(“Tekan Enter untuk selesai\n”);
do{
c = getch();
if(isspace(c))
break;
if(isalnum(c)){
if(islower(c))
printf(“%c adalah spasi\n”, c);
if(isupper(c))
printf(“%c adalah huruf besar\n”, c);
if(isdigit(c))
printf(“%c adalah angka\n”, c);
}
else putchar(‘7’);
}
while(1);
}

CONTOH III

#include <stdio.h>
#include <conio.h>
#include <string.h>
void strkiri(char st[], int n, char st[]);

main()
{
int i, panjangst;
char st[] = “ghvbhjklmlomkk”;
char strhasil[10];
panjangst=strlen(st);//
for (i=0;i<panjangst;i++){
strkiri(st, panjangst,strhasil);
printf(“%s\n”,strhasil);
}
getch();
}
void strkiri(char st[], int n, char strhasil[])
{
int i;
for (i=0; i<n; i++)
strhasil[i]=st[i];//
strhasil[i]=”;//
}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s