Advertisement
ferdhika31

Lat1601.c

Oct 25th, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.88 KB | None | 0 0
  1. Latihan 16. No.1
  2.  
  3. I.S  : A bernilai 24, dan B=52
  4. F.S  : Final State nilai A diketahui
  5. Kamus Data :
  6. A,B adalah variabel tunggal bertipe data integer  
  7. Algoritma :
  8.  
  9. while (A ≠ B) do
  10. begin
  11.   if (A > B)
  12.     then A ← A – B
  13.     else B ← B – A
  14.   endif
  15. endwhile
  16. write(layar) A
  17.  
  18.  
  19. /*
  20.     Program     : Lat1601.c
  21.     Deskripsi   : Menentukan Final State A setelah dilakukan proses tertentu  
  22.     Author      : AN
  23.     Compiler    : DevC                
  24.     Tanggal/Version : 23102015 V1.1
  25.     Ctt Lain    :
  26. */
  27.  
  28. #include<stdio.h>
  29.  
  30. int main(){
  31.     int A=24, B=52;
  32.    
  33.     /*Initial state A dan B dicetak */
  34.     printf("Initial State A = %d, B = %d \n\n",A,B);
  35.    
  36.    
  37.     /* Loop yang mengubah nilai A dan B */
  38.     while(A!=B) {
  39.         if(A>B){
  40.             A=A-B; 
  41.         }else{
  42.             B=B-A;
  43.         }
  44.         printf("A = %d, B = %d \n",A,B); //perubahan nilai A dan B dicetak
  45.     }
  46.    
  47.     printf("\n\nFinal State A = %d ", A);
  48.    
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement