external.cpp 642 B

123456789101112131415161718192021
  1. // external.cpp -- external variable
  2. // compile with support.cpp
  3. #include <iostream>
  4. // external variable
  5. double warming = 0.3; // warming defined
  6. // function prototypes
  7. void update(double dt);
  8. void local();
  9. int main() // uses global variable
  10. {
  11. using namespace std;
  12. cout << "Global warming is " << warming << " degrees.\n";
  13. update(0.1); // call function to change warming
  14. cout << "Global warming is " << warming << " degrees.\n";
  15. local(); // call function with local warming
  16. cout << "Global warming is " << warming << " degrees.\n";
  17. // cin.get();
  18. return 0;
  19. }