Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- // definisi fungsi dengan tipe void (Prosedur)
- void hello(int n=1) {
- for(int i=1;i<=n;i++) {
- cout << i << ". " << endl;
- cout << "Hello world!" << endl;
- cout << "Let's start the day with a cup of coffee" << endl;
- }
- }
- // definisi fungsi dengan tipe selain void (Fungsi)
- int tambah(int a, int b) {
- int hasil;
- hasil = a + b;
- return hasil;
- }
- int main()
- {
- hello();
- hello(tambah(7,9));
- cout << "hasil 7 ditambah 5 adalah " << tambah(7,5);
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement