Informasi Teknologi, Tutorial Blog Dan Pemrograman

Parameter Functions and Function Calling c + +

Parameter Functions and Function Calling c + +

Parameter Functions and Function Calling c + +



Function in c + + programming is a block of code designed to perform specific tasks.

The benefit of this function is

* to reduce the repetition of writing the same program

* for a more structured program so easy to understand and develop



Can we imagine if we are making the program more than a thousand lines and we have to repeat those programs manually

This course is very inefficient. In addition to energy waste and minds of our time is wasted too much. Well this is the function that will facilitate our

and accelerate our work.


Function in c + +, the function main (), this function is absolute, because this function the program will begin. Lots of functions in c + + programming

Another example is, the function int (), printf () which has the task to display the data to the screen, and many other functions.



Structure function


Here is the structure of writing a simple function:

nama_fungsi(argumen)
{
-pernyataan / perintah;
-pernyataan / perintah;
-pernyataan / perintah;
}

Nama fungsi dapat kita tuliskan secara bebas dengan ketentuan tidak
menggunakan spasi sebagai pemisah. pemisah nama fungsi menggunakan tanda _ .
Agumen kita letakan di dalam tanda kurung yang terletak di belakang nama fungsi, argumen boleh di isi dengan suatu data atau di biarkan kosong. Sedangkan pernyataan dan perintah di letakan diantara tanda { dan }, jangan sampai lupa akhiri perintah dengan titik koma ; . Untuk memanggil sebuah fungsi dapat kita panggil menggunakan nama fungsinya. Berikut ini adalah contoh pembuatan fungsi sederhana :

Program sederhana C++ Pembuatan Fungsi

#include
#include
#include

garis()
{
printf("\n--------------------------------------------------------\n");
}

/* program utamanya ini */
void main ()
{
garis(); // memanggil fungsi garis
cout<<" Teknik informatika universitas ahmad dahlan"<
#include
#include
tambah(int m, int n);
void main()
{
int a,b;
a=7;
b=9;
cout<<"Nilai sebelum fungsi Digunakan"; cout<<"/na="<<<"b="<<<"\nNilai setelah fungsi digunakan"; cout<<"\na="<<<"b="<<<"\n\nNilai di dalam Fungsi Tamba()"; cout<<"\nm="<<<"n="<<
#include
#include

tambah(int*c, int*d);
void mainI()
{

int a,b;
a=5;
b=6;
cout<<"Nilai Sebelum Pemanggilan fungsi";
cout<<"\na="<
<<"b="<
tambah(&a,&b);
cout<

cout<<"\nNilai Setelah Pemanggilan Fungsi:";
cout<<"\na="<
<<"b="<
getch();
}
{
*c+=7;
*d+=8;
cout<
cout<<"\nNilai akhir di fungsi tambah()";
cout<<"\nc="<<*c<<"d="<<*d;
cout<<"\nc="<<*c<<"d="<<*d;
}

Hopefully useful. We are sorry if there is a syntax error in the program because I was still learning basic stage and this post only for routine tasks memenuhui algorithms and programming course.


























































Posted by Unknown, Published at 07.16 and have 0 comments