fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a;
  6. int b;
  7. int c;
  8. double x;
  9. double y;
  10. double z;
  11.  
  12. a = 4;
  13. b = 15;
  14.  
  15. printf("a = %d, b = %d - both are integers \n", a,b);
  16.  
  17. c = a + b;
  18. printf("a + b = %d \n", c);
  19.  
  20. c = a - b;
  21. printf("a - b = %d \n", c);
  22.  
  23. c = a * b;
  24. printf("a * b = %d \n", c);
  25.  
  26. c = b / a;
  27. printf("b / a = %d \n", c);
  28.  
  29. c = a / b;
  30. printf("a / b = %d \n", c);
  31.  
  32. c = b % a;
  33. printf("b \%% a = %d (\%% means \"remainder of\") \n", c);
  34.  
  35. printf("\n ---*D*O*U*B*L*E* *T*I*M*E*!*--- \n");
  36.  
  37. x = 4;
  38. y = 15;
  39.  
  40. printf("x = %lf, y = %lf - both are doubles \n", x,y);
  41.  
  42. z = x + y;
  43. printf("x + y = %lf \n", z);
  44.  
  45. z = x - y;
  46. printf("x - y = %lf \n", z);
  47.  
  48. z = x * y;
  49. printf("x * y = %lf \n", z);
  50.  
  51. z = y / x;
  52. printf("y / x = %lf \n", z);
  53.  
  54. z = x / y;
  55. printf("x / y = %lf \n", z);
  56.  
  57. return 0;
  58. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
a = 4, b = 15 - both are integers 
a + b = 19 
a - b = -11 
a * b = 60 
b / a = 3 
a / b = 0 
b % a = 3       (% means "remainder of") 

 ---*D*O*U*B*L*E* *T*I*M*E*!*--- 
x = 4.000000, y = 15.000000 - both are doubles 
x + y = 19.000000 
x - y = -11.000000 
x * y = 60.000000 
y / x = 3.750000 
x / y = 0.266667