#include <iostream.h>
class Bilangan{
friend istream& operator>>(istream&, Bilangan&);
friend ostream& operator<<(ostream&, const Bilangan&);
public :
Bilangan();
void urai();
private:
int bilangan;
int ratusan, puluhan, satuan;
};
istream& operator>>(istream& in, Bilangan& X){
cout<<"Masukkan bilangan ";in>>X.bilangan;
return in;
}
ostream& operator<<(ostream&, const Bilangan& X );
out<<X.bilangan<<" Setelah diurai maka menjadi "<<endl;
out<<"ratusan "<<X.ratusan<<endl;
out<<"puluhan "<<X.puluhan<<endl;
out<<"satuan "<<X.satuan<<endl;
return out;
}
//fungsi urai
void Bilangan::urai(){
ratusan = bilangan/100;
bilangan = bilangan% 100;
puluhan = bilangan/10;
satuan = bilangan%10;
}
//fungsi main
int main(){
Bilangan X;
cin>>X;
X.urai();
cout<<X;
return 0;
}
Artikel Terkait:
Belajar Struktur Data
- Class Inheritance
- Recursion Shortest Function to Reverse a String
- Calculator (C++)
- Calling functions with Inline Assembly
- Struktur Data Tree (Pohon)
- Struktur Data Queue (Antrian)
- Struktur Data Stack
- Jawaban Pretest & Post Test Praktikum IV (Struktur Data)
- Laporan Praktikum II Struktur Data
- Laporan Diskusi Minggu II
- Pemrograman Dasar C++
- Abtrak Data Type
Algoritma dan Pemrograman
- Class Inheritance
- OOP Recursive Decent Parsing III
- OOP Recursive Decent Parsing II
- OOP Recursive Decent Parsing I
- Calculate Sequebce by Using Iterative Function
- A Comparison of Sorting Algorithms
- Typical data sequences for testing sorting algorithms
- Quicksort Algorithm
- Vector
- Function to reverse an integer array
- Array
- String Contains function
- RECCURENCE RELATION
- Recursion
- Recursion Shortest Function to Reverse a String
- Calculator (C++)
- Recursive Format numbers with commas
- Calling functions with Inline Assembly
- Recursive Function
- Algoritma Menentukan Tahun Kabisat
- Algoritma dan Class Bilangan Prima
- Class Luas Lingkaran dan Volume Bola With Jeliot
- Struktur Perulangan (Lanjutan)
- Struktur Perulangan
Comments :
0 comments to “Class Bilangan [Bahasa C++]”
Post a Comment