Saturday, 10 October 2015
Bahasa Pemrograman : Struktur Data 02
Struct & Class
1. Main
#include <conio.h>
#include <iostream.h>
int main(){
float bil1=0,bil2=0,jumlah;
cout<<"Masukan Bilangan A : "; cin>>bil1;
cout<<"Masukan Bilangan B : "; cin>>bil2;
jumlah =bil1+bil2;
cout<<"Jumlah "<<bil1<<" + "<<bil2<<" = "<<jumlah;
getch();
)
2. Fungsi
void masukandata(float &bil1,float &bil2){
cout<<"Masukan Bilangan A : "; cin>>A;
cout<<"Masukan Bilangan B : "; cin>>B;
jumlah =A+B;
)
float jumlahkan(float bil1,float bil2){
float jumlah;
jumlah=0;
jumlah=bil1+bil2;
return jumlah;
}
float tampilkan(float bil1,float bil2,jumlah){
cout<<"Jumlah "<<bil1<<" + "<<bil2<<" = "<<jumlah;
return jumlah;
}
3. Struct
Struct Bilangan{
float bil1;
float bil2;
}
Bilangan x;
masukandata(x.bil1,x.bil2);
float jumlah;
jumlah=jumlah(x.bil1,x.bil2);
tampilkan(x.bil1,x.bil2,jumlah);
}
4. Class
Class Bilangan{
public:
void masukandata();
float jumlah();
void tampilkan();
private:
float bil1;
float bil2;
float jumlah;
}
Bilangan x;
x.masukandata();
x.jumlah();
x.tampilkan();
Subscribe to:
Post Comments (Atom)
R-chord 謝和弦 - I'm Not Your Prince Charming 我不是白馬王子 Lyrics 歌詞 with Pinyin
R-chord 謝和弦 x 高爾宣 & 李傑明 - I'm Not Your Prince Charming 我不是白馬王子 (Wo Bu Shi Bai Ma Wang Zi) Lyrics 歌詞 with Pinyin | 謝和弦 我不是白馬王子 歌詞 ...
-
He Yi Hang 賀一航 - Please Say Hello First 請先說你好 (Qing Xian Shuo Ni Hao) Lyrics 歌詞 with Pinyin | 賀一航 請先說你好 歌詞 Singer: He Yi Hang 賀一航 Album: Ple...
-
Wang Yi Tai 王以太 - Mu Bu Zhuan Jing 目不轉睛 Lyrics 歌詞 with Pinyin | 王以太 目不轉睛 歌詞 Singer: Wang Yi Tai 王以太 Album: Mu Bu Zhuan Jing 目不轉睛 Title: Mu B...
-
Ann 白安 - After You Left 離開後 (Li Kai Hou) Lyrics 歌詞 with Pinyin | 白安 離開後 歌詞 Singer: Ann 白安 Album: 1990s Title: 離開後 (Li Kai Hou) English Title...
No comments:
Post a Comment