fork download
  1. #include <stdio.h>
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4.  
  5. void example1(void) {
  6. int8_t x1;
  7. uint8_t x2;
  8. uint8_t temp_a;
  9. uint8_t temp_b;
  10. _Bool first_condition;
  11. _Bool second_condition;
  12.  
  13. x1 = -1;
  14. x2 = 1;
  15.  
  16. temp_a = (uint8_t) x1;
  17. temp_b = (int8_t) x2;
  18.  
  19. first_condition = (temp_a > x2);
  20. second_condition = (x1 > temp_b);
  21.  
  22. printf("As UNSIGNED: ");
  23. if(first_condition) {
  24. printf("x1 > x2\n");
  25. }
  26. else {
  27. printf("x1 <= x2\n");
  28. }
  29.  
  30. printf("As SIGNED: ");
  31. if(second_condition) {
  32. printf("x1 > x2\n");
  33. }
  34. else {
  35. printf("x1 <= x2\n");
  36. }
  37. }
  38.  
  39. int main(void) {
  40. example1();
  41. return 0;
  42. }
  43.  
  44.  
Success #stdin #stdout 0s 4524KB
stdin
Standard input is empty
stdout
As UNSIGNED: x1 > x2
As SIGNED: x1 <= x2