Senin, 18 April 2011

Program untuk menggabungkan 2 angka

#include <iostream.h>
#include <conio.h>
#include <string.h>
class gabung{
        friend ostream& operator<<(ostream&,gabung&);
        friend istream& operator>>(istream&,gabung&);
public:
        void kata();
private:
        char kata1[10];
   char kata2[19];
};

istream&operator>>(istream&in,gabung&x){
        cout<<"\nmasukian bilangan 1 :";
        in>>x.kata1;
        cout<<"masukan bilangan 2 :";
        in>>x.kata2;
        x.kata();
        return in;
}

ostream&operator<<(ostream& out,gabung&x)
{
        out<<"hailnya :"<<x.kata1<<endl;
        return out;
}
void gabung::kata(){

        strcat(kata1,kata2);
        cout<<"kata gabungan : "<<kata1<<endl;

}

void main(){
        gabung a;
   cin>>a;
   cout<<a;
   getch();
return 0;
}

Reaksi:

0 komentar:

Posting Komentar

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Blogger Theme by Lasantha - Premium Blogger Templates | Affiliate Network Reviews