Program C++ Membalik Kalimat


Script
#include <stdio.h>
#include <conio.h>
#include <iostream.h>

main() {
char kalimat[100];
char *p;
char m;
char *k;
k=&m;
int a,b;

printf (“|========================|\n”);
printf (“|Program Pembalik Kalimat|\n”);
printf (“|========================|\n\n\n”);

printf(“Masukkan kalimat = “);
gets(kalimat);
a=strlen(kalimat);
p=kalimat;

for(b=0;b<((a/2));b++){
*(k+b)= *(p+a-(b+1));
*(p+a-(b+1))= *(p+b);
*(p+b)= *(k+b);
}

printf(“\nHasil Pembalikan = %s”,kalimat);
getche ();
}
Hasil

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