Skip to content

Instantly share code, notes, and snippets.

@madduci
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madduci/3ca2841b9e175c1f843e to your computer and use it in GitHub Desktop.
Save madduci/3ca2841b9e175c1f843e to your computer and use it in GitHub Desktop.
Playing with variables
/*
Author: Michele Adduci <info@micheleadduci.net>
*/
#include <iostream>
#include <cmath>
int main()
{
std::cout << "The result of 3*3 is " << 3*3 << std::endl;
int var_a = 3*3;
int var_a_2 {3*3};
std::cout << "The result of 3*3 is " << var_a << std::endl;
std::cout << "Var A_2 is " << var_a_2 << std::endl;
double var_b = 45.2/3.8*12;
std::cout << "The result of 45.2/3.8*12 is " << var_b << std::endl;
int var_c {var_b};
auto var_d = var_b;
std::cout << "Var C is " << var_c << std::endl
<< "Var D is " << var_d << std::endl;
char var_e {'A'};
int var_f {var_e}; //check this out
auto var_g = var_e; //spot the difference here
std::cout << "Var E is " << var_e << std::endl
<< "Var F is " << var_f << std::endl
<< "Var G is " << var_g << std::endl;
auto var_sqrt = std::sqrt(150);
std::cout << "The square root of 150 is " << var_sqrt << std::endl;
auto var_pow = std::pow(2, 3); //2^3 = 2*2*2
std::cout << "2^3 is " << var_pow << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment