Dave's Brain

Browse - Programming Tips - Can I use Greek letters as variable names to more compactly express my formulas?

Date: 2014oct30
Language: C/C++
Product: clang

Q.  Can I use Greek letters as variable names to more compactly express my formulas?

A.  Yes, clang (as of version 3.3) supports Greek letters as variable
names.   All the lowercase letters are listed here.  You can copy and paste
directly into your code.

#include <math.h> #include <iostream> int main() { double α; // alpha double β; // beta double γ; // gamma double δ; // delta double ε; // epsilon double ζ; // zeta double η; // eta double θ; // theta double ι; // iota double κ; // kappa double λ; // lambda double μ; // mu double ν; // nu double ξ; // xi double ο; // omicron double π = M_PI; // pi double ρ; // rho double ς; // final sigma double σ; // small sigma double τ; // tau double υ; // upsilon double φ; // phi double χ; // chi double ψ; // psi double ω; // omega // The area of a circle double r = 10.0; // radius double A = π * r * r; std::cout << "Area is " << A << std::endl; }

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.