Tuesday, 17 April 2012

program with the word flip-recursive iterative looping

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

class Balik{
friend istream& operator>>(istream&, Balik&);
friend ostream& operator<<(ostream&, Balik&);
public:

void balik_kata();
void balik(int s);
private:
char kata[50];
int n;
};
void Balik::balik_kata(){ //interatif
cout<<"Masukkan Kata : ";
cin>>kata;n=strlen(kata);
cout<<"Hasil Kata : ";

balik(n);
}
void Balik::balik(int s){ // rekursif
if (s != -1){
cout<<kata[s];
balik(s-1);
}
}
int main()
{
Balik X;
X.balik_kata();
system ("Pause");
return EXIT_SUCCESS;

}

0 comments:

Post a Comment

.

.

.

.
Design by BlogSpotDesign | Ngetik Dot Com