Here I will discuss how to use modulus to separate a value, so that we can use it according to our purposes. For example, here I want to use it for my memebantu reverse the order of a value. 1234 inputkan our example, then the output 4321.
For the process as follows :
void balik::proses(){
a = nilai / 1000;
b = nilai % 1000;
c = b / 100;
d = b % 100;
e = d / 10;
f = d % 10;
}
The final step adapted to living calling purposes only. In order not curious please download the program at here
How to find value? We can make use of recursive programs. Now we see a plus sign (+) min (-) it. How do I tell? Absolutely, which is worth an odd marked plus (+) and a marked positive value min (-). From these observations we can use it as a key telling the program making.
Now we make a recursive program :
Proses_rekursif(int n){
if(n==0) return 0;
else if(n==1) return 1;
else if(n%2==0) return (-(1.0/n)+(proses2(n-1)));
else return ((1.0/n)+(proses2(n-1)));
}
You're curious about the full results? Definitely curious! DownloadHERE.
Buat temen – temen yang sempat mampir diblog saya ini, ada permainan seru lagi yang bisa dicoba. Permainan ini saya dapat dari dosen saya. Berapa kali kalian mencoba sehingga kalian menemukan nilai yang benar?! Hasil dari percobaan anda bisa ditulis dikomentar. Rekor tertinggi saya tunggu..
Recursive means that a process can call itself. Recursive definition is actually contained in the procedures and functions. The difference is that the recursive call to itself can be, but the procedures and functions must be called by the caller procedures and functions. Recursive programming techniques are important and some programming languages support the existence of this recursive process. In procedures and functions, the call to itself can mean an iterative process that can not be known when it will end.
Now I will make an example of multiplication program (axb = a + a + a +...+ a total b times) by using recursive. Multiplication recursively can be written as follows :