Skip to content

Instantly share code, notes, and snippets.

@ananace
Last active August 29, 2015 13:57
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 ananace/9649624 to your computer and use it in GitHub Desktop.
Save ananace/9649624 to your computer and use it in GitHub Desktop.

Examples:

Ruby:

variable = 5

if variable > 4 then
    puts variable.to_s + " is over 4"
    puts "It's exactly five" if variable == 5
elsif variable == 4 then
    puts "It's four"
end

(1..10).each do |i|
    puts i.to_s + " a thousand."
end

Python:

variable = 5

if variable > 4:
    print variable, "is over 4"
    if variable == 5:
        print "It's exactly five"
elif variable == 4:
    print "It's four"
    
for i in range(1,11):
    print i, "a thousand."

C++:

int variable = 5;

if (variable > 4)
{
    std::cout << variable << " is over 4" << std::endl;
    if (variable == 5)
        std::cout << "It's exactly five" << std::endl;
}
else if (variable == 4)
{
    std::cout << "It's four" << std::endl;
}

for (int i = 1; i < 11; ++i)
{
    std::cout << i << " a thousand" << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment