C++ Tutorial · Chapter 5 of 13
C++ Variables
Declare and use typed variables.
Examples: int score; double average; string name;
string needs #include <string> in stricter setups; many classroom samples still work with iostream included first.
Variable sample
Try it Yourself »
#include <iostream>
using namespace std;
int main() {
int age = 18;
cout << "Age: " << age << endl;
return 0;
}
Classroom Tips
- Choose meaningful names.
- Initialize before use.