Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3. Online C Compiler.
  4. Code, Compile, Run and Debug C program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <stdio.h>
  10.  
  11. int main(){
  12.  
  13. float a, b, c, d, e, f;
  14. int g;
  15.  
  16. printf("Inputkan nilai a: ");
  17. scanf("%f", &a);
  18.  
  19. printf("Inputkan nilai b: ");
  20. scanf("%f", &b);
  21.  
  22. //Penjumlahan
  23. c = a + b;
  24. printf("Hasil a + b: %.2f \n", c);
  25.  
  26. //Pengurangan
  27. d = a - b;
  28. printf("Hasil a - b: %.2f \n", d);
  29.  
  30. //Perkalian
  31. e = a * b;
  32. printf("Hasil a * b: %.2f \n", e);
  33.  
  34. //Pembagian
  35. f = a / b;
  36. printf("Hasil a / b: %.2f \n", f);
  37.  
  38. //Persen
  39. g = (int) a % (int) b;
  40. printf("Hasil a % b: %i \n", g);
  41.  
  42. //Penjumlahan Unik
  43. b += a;
  44. printf("Hasil a += b: %.2f \n", b);
  45.  
  46. //Perkalian Unik
  47. b *= a;
  48. printf("Hasil a *= b: %.2f \n", b);
  49.  
  50.  
  51.  
  52.  
  53. return 0;
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement