3 Ways To Say I Love You (In Code)

Example 1:

#include <iostream>
#include <cstdlib>

using namespace std;

int main() {
  int two;
  two = 1;
  while(two == 1) {
    cout << "I love you little red haired girl\n";
  }
}

Example 2:

#include <iostream>
#include <cstdlib>

using namespace std;

void myLoveGrowsDeeper(int lvl);

int main() {
  int lvl = 1;
  cout << "My love grows deeper";
  myLoveGrowsDeeper(lvl);
  cout << " every day." << endl;
}

void myLoveGrowsDeeper(int lvl) {
  if(lvl == 99) {
    return;
  }
  myLoveGrowsDeeper(lvl+1);
  cout << " and deeper ";
}

Example 3 (Turtle Commands, Pixels, Degrees):

LEFT 45
FORWARD 100
REPEAT 180
  FORWARD PI/2
  LEFT 1
RIGHT 90
REPEAT 180
  FORWARD PI/2
  LEFT 1
FORWARD 100





Advertisements

2 Comments

Filed under Trube On Tech

2 responses to “3 Ways To Say I Love You (In Code)

  1. Nice touch with the turtle commands!

  2. aren’t you just the sweetest!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s