What is volatile keyword?
-The volatile keyword is intended to prevent the compiler from applying any optimizations on objects that can change in ways that cannot be determined by the compiler.
-Objects declared as volatile are omitted from optimization because their values can be changed by code outside the scope of current code at any time.
program:
#include < iostream>
using namespace std;
int main()
{
int volatile num;
cout<<"Enter numbern";
cin>>num;
cout<<"Number is: "<< num;
return 0;
}
Enter number
34
Number is: 34