C++ examples for Data Type:auto
Define auto type variable and do math calculation on them
#include <iostream> int main() // www.ja v a 2s .com { // define character values auto strength = 8; auto accuracy = 4.5; auto dexterity = 2.0; // define constants const auto MAXIMUM = 50; // calculate character combat stats auto attack = strength * (accuracy / MAXIMUM); auto damage = strength * (dexterity / MAXIMUM); std::cout << "\nAttack rating: " << attack << "\n"; std::cout << "Damage rating: " << damage << "\n"; }