Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Latihan 16. No.1
- I.S : A bernilai 24, dan B=52
- F.S : Final State nilai A diketahui
- Kamus Data :
- A,B adalah variabel tunggal bertipe data integer
- Algoritma :
- while (A ≠ B) do
- begin
- if (A > B)
- then A ← A – B
- else B ← B – A
- endif
- endwhile
- write(layar) A
- /*
- Program : Lat1601.c
- Deskripsi : Menentukan Final State A setelah dilakukan proses tertentu
- Author : AN
- Compiler : DevC
- Tanggal/Version : 23102015 V1.1
- Ctt Lain :
- */
- #include<stdio.h>
- int main(){
- int A=24, B=52;
- /*Initial state A dan B dicetak */
- printf("Initial State A = %d, B = %d \n\n",A,B);
- /* Loop yang mengubah nilai A dan B */
- while(A!=B) {
- if(A>B){
- A=A-B;
- }else{
- B=B-A;
- }
- printf("A = %d, B = %d \n",A,B); //perubahan nilai A dan B dicetak
- }
- printf("\n\nFinal State A = %d ", A);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement