auto keyword in C++ by R4R Team

Auto keyword:
-Here auto refers as automatically.
-The auto keyword specifies that the type of the variable that is being declared will be automatically deducted from its initializer.
-auto becomes int type if even an integer reference is assigned to it


#include < iostream>
using namespace std;
int main()
//Here i is automatically integer number
auto i=10;
//Here f is autommatically float number
auto f=4.1;
cout<<"Value of i is: "<< i<< endl;
cout<<"Value of j is: "<< f;
return 0;


Value of i is: 10
Value of j is: 4.1

-In this program, the data_type of the variable is automatically decided by the compiler due to the auto keyword.

Leave a Comment:
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on 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!