Volatile keyword in C++ by R4R Team

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;
}


output-

Enter number
34
Number is: 34




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!