Functions the same as the procedure but the function can return a value.
Such functions are identified by using various data types be it int, float, double and charat the end of the function which will be returned using the return of the variables that are calculated or would at last show.
As with any procedure also function held before or after the main function.
Such functions are identified by using various data types be it int, float, double and charat the end of the function which will be returned using the return of the variables that are calculated or would at last show.
As with any procedure also function held before or after the main function.
This is an example of a simple function and the way calling :
#include <iostream>
int penjumlahan(){
int a, b, jumlah;
cin >>a;
cin>>b;
jumlah = a+b;
return jumlah;
}
int main{
penjumlahan();
return 0;
}
Tidak ada komentar:
Posting Komentar