fork download
  1. // Definition and use of variables
  2. #include <iostream>
  3. using namespace std;
  4. int gVar1; // Global variables,
  5. int gVar2 = 2; // explicit initialization
  6. int main()
  7. {
  8. char ch('A'); // Local variable being initialized
  9. // or: char ch = 'A';
  10. cout << "Value of gVar1: " << gVar1 << endl;
  11. cout << "Value of gVar2: " << gVar2 << endl;
  12. cout << "Character in ch: " << ch << endl;
  13. int sum, number = 3; // Local variables with
  14. // and without initialization
  15. sum = number + 5;
  16. cout << "Value of sum: " << sum << endl;
  17. return 0;
  18. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Value of gVar1: 0
Value of gVar2: 2
Character in ch: A
Value of sum: 8