Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdbool.h>
  4. // para uso do "bool" em C99;
  5.  
  6. // para compiladores anteriores, use:
  7. // #define bool int;
  8. // #define true 1;
  9. // #define false 0;
  10.  
  11. // exemplo linha 86 em 3.variáveis.txt;
  12.  
  13. int main()
  14. {
  15.     // declaração de variável;
  16.     int x, y;
  17.     bool xbemmaior;
  18.    
  19.     // atribuição de variável (valor no domínio do tipo);
  20.     x = 2;
  21.     y = 3;
  22.  
  23.     // atribuição de variável (expressão de valor);
  24.     x += y; // x = x + y;
  25.     printf("x=%d\n", x);
  26.     y += x; // y = y + x;
  27.     printf("y=%d\n", y);
  28.     x = 2 * x + y;
  29.     printf("x=%d\n", x);
  30.     printf("3 * y=%d\n", 3 * y);
  31.  
  32.     // variável do tipo lógico (true or false);
  33.     xbemmaior = (x > (3 * y));
  34.     if (xbemmaior = true)
  35.     {
  36.         printf("Verdade\n");
  37.     }
  38.     else
  39.     {
  40.         printf("Falso\n");
  41.     }
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement