Advertisement
campos20

Untitled

Jun 2nd, 2020
901
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. // Variavel global, visivel no programa todo
  5. int idade = 30;
  6.  
  7. void mostrar_variavel_global(){
  8.     printf("O valor da variabel global e: %d\n", idade);
  9. }
  10.  
  11. int main()
  12. {
  13.     printf("Idade: %d\n", idade);
  14.     mostrar_variavel_global();
  15.  
  16.     {
  17.         // Idade global e sobrescrita de 30 para 20
  18.         int idade = 20;
  19.         printf("Idade no escopo: %d\n", idade);
  20.     }
  21.  
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement