c++ watch a variable
Watch a Variable in C++
#include <iostream>
using namespace std;
int main() {
int x = 5;
cout << "Initial value of x: " << x << endl;
x = 10;
cout << "New value of x: " << x << endl;
return 0;
}
In this example, we declare a variable x
and initialize it with the value 5. We then output the initial value of x
using cout
. Next, we update the value of x
to 10 and output the new value using cout
. Finally, the program returns 0, indicating successful execution.