You are on page 1of 1

Class Cek Karakter huruf kecil atau besar #include <iostream.h> #include <conio.

h> class Kecbesdig{ friend ostream& operator<<(ostream& , const Kecbesdig&); friend istream& operator>>(istream& , Kecbesdig&); public: Kecbesdig(){}; private: char a; }; ostream& operator<<(ostream& out, const Kecbesdig& C) { if (((int)C.a>=65) && ((int)C.a<=90)) out << C.a<< " adalah Huruf Besar\n"; if (((int)C.a>=97) && ((int)C.a<=122))out << C.a << " adalah Huruf kecil\n"; if (((int)C.a>=48) && ((int)C.a<=57)) out << C.a << " adalah Angka\n"; if (((int)C.a>=33) && ((int)C.a<=47)) out << C.a <<" adalah operator\n"; return out; } istream& operator>>(istream& in,Kecbesdig& C){ cout<<"Masukkan sebuah karacter sembarang : ";in>>C.a; return in; } int main (){ Kecbesdig p; cout<<"Program ini menginisialisasi input yang dimasukkan oleh user\n"<<endl; cin>>p; cout<<p<<endl; getch(); return 0; }

You might also like